@vue-pdf-viewer/viewer 4.4.0 → 4.5.0-beta.0
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/dist/{VPdfViewer.vue_vue_type_style_index_1_scoped_1bbfb09f_lang-Db2k8vVi.js → VPdfViewer.vue_vue_type_style_index_1_scoped_268656f1_lang-B6dm5SQl.js} +1656 -1583
- package/dist/VPdfViewer.vue_vue_type_style_index_1_scoped_268656f1_lang-BK2suzT0.cjs +48 -0
- package/dist/{index-BVrAKMVi.js → index-Bl63Fqfe.js} +1 -1
- package/dist/index-DB3mTYRF.cjs +27 -0
- package/dist/index.cjs +24 -17
- package/dist/index.js +11422 -10782
- package/dist/license.cjs +1 -1
- package/dist/license.js +4 -4
- package/dist/types/components/VPdfPage.vue.d.ts +6 -1
- package/dist/types/composables/useLazyPageFetch.d.ts +40 -0
- package/dist/types/composables/useNetworkRecovery.d.ts +24 -0
- package/dist/types/composables/usePdf.d.ts +19 -0
- package/dist/types/composables/usePdfActualPages.d.ts +20 -3
- package/dist/types/composables/usePlugins.d.ts +1 -1
- package/dist/types/composables/useSearch.d.ts +2 -2
- package/dist/types/composables/useVirtualPages.d.ts +11 -0
- package/dist/types/const.d.ts +6 -0
- package/dist/types/utils/boundedConcurrency.d.ts +15 -0
- package/dist/types/utils/documentLayout.d.ts +73 -0
- package/dist/types/utils/highlight.d.ts +11 -1
- package/dist/types/utils/searchHighlight.d.ts +1 -3
- package/dist/types/utils/types.d.ts +18 -2
- package/package.json +3 -2
- package/dist/VPdfViewer.vue_vue_type_style_index_1_scoped_1bbfb09f_lang-tQybRRWM.cjs +0 -48
- package/dist/index-o6CBDGmL.cjs +0 -27
- package/dist/types/components/LayerTextSearchHighlight.vue.d.ts +0 -19
package/dist/license.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./VPdfViewer.
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./VPdfViewer.vue_vue_type_style_index_1_scoped_268656f1_lang-BK2suzT0.cjs");exports.LicenseProduct=e.P;exports.LicenseType=e.Q;exports.useLicense=e.b3;
|
package/dist/license.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { P as c, Q as a, b3 as i } from "./VPdfViewer.vue_vue_type_style_index_1_scoped_268656f1_lang-B6dm5SQl.js";
|
|
2
2
|
export {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
c as LicenseProduct,
|
|
4
|
+
a as LicenseType,
|
|
5
|
+
i as useLicense
|
|
6
6
|
};
|
|
@@ -3,7 +3,12 @@ import type { PDFDocumentProxy } from 'pdfjs-dist';
|
|
|
3
3
|
import type { CanvasLoadedCallback, AnnotationEventPayload, HighlightEventPayload, HighlightOptions, MatchValue, TextLayerLoadedEventPayload, TextHighlight, CanvasRenderedEventPayload, VisibleArea } from '../utils/types';
|
|
4
4
|
interface BaseProps {
|
|
5
5
|
pageIndex: number;
|
|
6
|
-
|
|
6
|
+
/**
|
|
7
|
+
* `null` while this page's dimensions are still estimated. The component then renders
|
|
8
|
+
* a correctly sized shell (`.vpv-page` + loader) and mounts no layers, so geometry is
|
|
9
|
+
* identical to a real page and the scoped `.vpv-page` styles still apply.
|
|
10
|
+
*/
|
|
11
|
+
page: PDFPageProxy | null;
|
|
7
12
|
viewport: PageViewport;
|
|
8
13
|
document: PDFDocumentProxy;
|
|
9
14
|
afterCanvasLoaded?: CanvasLoadedCallback;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { type Ref, type ShallowRef } from 'vue';
|
|
2
|
+
import type { PDFDocumentProxy } from 'pdfjs-dist';
|
|
3
|
+
import type { PDFPageProxy } from 'pdfjs-dist/types/web/interfaces';
|
|
4
|
+
import type { ViewerPdfPage } from '@/utils/types';
|
|
5
|
+
/**
|
|
6
|
+
* pdf.js skips eager page initialisation past this size; beyond it, firing N getPage()
|
|
7
|
+
* calls costs more than it saves and pages are fetched purely on demand.
|
|
8
|
+
*/
|
|
9
|
+
declare const FORCE_LAZY_PAGE_INIT = 5000;
|
|
10
|
+
export interface LazyFetchState {
|
|
11
|
+
isActive: boolean;
|
|
12
|
+
fetchedCount: number;
|
|
13
|
+
totalPages: number;
|
|
14
|
+
isComplete: boolean;
|
|
15
|
+
}
|
|
16
|
+
export interface UseLazyPageFetchOptions {
|
|
17
|
+
rotation: Ref<number>;
|
|
18
|
+
}
|
|
19
|
+
export interface UseLazyPageFetchReturn {
|
|
20
|
+
ensurePageLoaded: (pageIndex: number) => Promise<PDFPageProxy | null>;
|
|
21
|
+
startEagerFetch: () => Promise<void>;
|
|
22
|
+
/** Retry pages whose fetch failed; called when the network comes back. */
|
|
23
|
+
retryFailedPages: () => void;
|
|
24
|
+
fetchState: Ref<LazyFetchState>;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Background and on-demand page fetching for documents whose dimensions started as
|
|
28
|
+
* estimates.
|
|
29
|
+
*
|
|
30
|
+
* Owns three jobs:
|
|
31
|
+
* - eager background fetch of pages 2..N, batched per animation frame
|
|
32
|
+
* - on-demand fetch when the viewport (or a thumbnail) reaches an estimated page
|
|
33
|
+
* - retry of pages whose fetch failed, including when connectivity returns
|
|
34
|
+
*
|
|
35
|
+
* Entries are corrected in place; a single shallow replacement per batch keeps the
|
|
36
|
+
* reactivity cost independent of batch size.
|
|
37
|
+
*/
|
|
38
|
+
export declare function useLazyPageFetch(pdfDocument: ShallowRef<PDFDocumentProxy | undefined>, pdfPages: ShallowRef<ViewerPdfPage[]>, options: UseLazyPageFetchOptions): UseLazyPageFetchReturn;
|
|
39
|
+
export { FORCE_LAZY_PAGE_INIT };
|
|
40
|
+
export default useLazyPageFetch;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { type Ref } from 'vue';
|
|
2
|
+
import type { PDFDocumentProxy } from 'pdfjs-dist';
|
|
3
|
+
interface UseNetworkRecoveryOptions {
|
|
4
|
+
/** Open the same source again in a new loading task. Returns false if it cannot. */
|
|
5
|
+
reopen: () => boolean;
|
|
6
|
+
/** A reopen failed and is waiting to run again; there is no document meanwhile. */
|
|
7
|
+
isReopenPending: () => boolean;
|
|
8
|
+
/** Retry the pages whose fetch failed, in the current document. */
|
|
9
|
+
retryFailedPages: () => void;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Bring pages back after the network returns from an offline period.
|
|
13
|
+
*
|
|
14
|
+
* pdf.js cannot recover from a failed range request in the same document: its worker keeps
|
|
15
|
+
* the chunks of the failed request marked as requested (`ChunkedStreamManager._requestsByChunk`
|
|
16
|
+
* is only cleared when data arrives), so every later read of them waits forever, and the
|
|
17
|
+
* main thread caches the rejected `getPage()` promise. Pages that failed while offline
|
|
18
|
+
* therefore stay blank, and retrying them sends nothing (VPV-2590). Until pdf.js handles
|
|
19
|
+
* this, the only way back is a new loading task for the same source.
|
|
20
|
+
*
|
|
21
|
+
* The reopen is skipped once the whole file is in memory, since nothing can fail after that.
|
|
22
|
+
*/
|
|
23
|
+
declare function useNetworkRecovery(pdfDocument: Ref<PDFDocumentProxy | undefined>, { reopen, isReopenPending, retryFailedPages }: UseNetworkRecoveryOptions): void;
|
|
24
|
+
export default useNetworkRecovery;
|
|
@@ -2,8 +2,27 @@ 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
4
|
export declare function configWorker(workerSrc?: string, legacy?: boolean): void;
|
|
5
|
+
/**
|
|
6
|
+
* @typedef {Object} UsePDFParameters
|
|
7
|
+
* @property {string} password
|
|
8
|
+
* Document password to unlock content
|
|
9
|
+
* @property {function} onProgress
|
|
10
|
+
* Callback to request a password if a wrong or no password was provided. The callback receives two parameters: a function that should be called with the new password, and a reason (see PasswordResponses).
|
|
11
|
+
* @property {function} onPassword
|
|
12
|
+
* Callback to be able to monitor the loading progress of the PDF file (necessary to implement e.g. a loading bar). The callback receives an OnProgressParameters argument. if this function is used option.password is ignored
|
|
13
|
+
* @property {function} onError
|
|
14
|
+
* Callback to be able to handle errors during loading
|
|
15
|
+
* */
|
|
16
|
+
/**
|
|
17
|
+
*
|
|
18
|
+
* @param {string | URL | TypedArray | PDFDataRangeTransport | DocumentInitParameters} src
|
|
19
|
+
* Can be a URL where a PDF file is located, a typed array (Uint8Array) already populated with data, or a parameter object.
|
|
20
|
+
* @param {UsePDFParameters} options
|
|
21
|
+
* UsePDF object parameters
|
|
22
|
+
*/
|
|
5
23
|
declare function usePdf(src: MaybeRef<PDFSrc>, options?: PDFOptions, workerUrl?: string, documentOptions?: PDFDocumentOptions, wasmUrl?: string): {
|
|
6
24
|
pdfDocLoadingTask: import("vue").ShallowRef<import("pdfjs-dist/types/src/display/api").PDFDocumentLoadingTask | undefined, import("pdfjs-dist/types/src/display/api").PDFDocumentLoadingTask | undefined>;
|
|
7
25
|
getPage: (doc: PDFDocumentProxy, pageIndex: number) => Promise<PDFPageProxy>;
|
|
26
|
+
reload: () => boolean;
|
|
8
27
|
};
|
|
9
28
|
export default usePdf;
|
|
@@ -1,5 +1,20 @@
|
|
|
1
|
-
import { Reactive } from 'vue';
|
|
2
|
-
import { ViewerPdfPage, ViewerState } from '@/utils/types';
|
|
1
|
+
import { Reactive, Ref } from 'vue';
|
|
2
|
+
import { PDFSrc, ViewerPdfPage, ViewerState } from '@/utils/types';
|
|
3
|
+
/**
|
|
4
|
+
* Whether a source can be laid out from estimated dimensions.
|
|
5
|
+
*
|
|
6
|
+
* Only sources pdf.js fetches incrementally benefit: page 1's metadata can resolve long
|
|
7
|
+
* before the rest of the file arrives. In-memory sources already hold every byte, so
|
|
8
|
+
* estimating would add a correction pass for no gain.
|
|
9
|
+
*/
|
|
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;
|
|
3
18
|
/**
|
|
4
19
|
* Composable for managing PDF pages at base scale (100%).
|
|
5
20
|
*
|
|
@@ -12,10 +27,12 @@ import { ViewerPdfPage, ViewerState } from '@/utils/types';
|
|
|
12
27
|
* @param props - The viewer state containing PDF document and rotation settings
|
|
13
28
|
* @returns Object containing pdfPages (all pages) and filteredPages (view-mode filtered)
|
|
14
29
|
*/
|
|
15
|
-
declare function usePdfActualPages(props: Reactive<ViewerState>): {
|
|
30
|
+
declare function usePdfActualPages(props: Reactive<ViewerState>, source?: Ref<PDFSrc | undefined>): {
|
|
16
31
|
/** All pages at base scale (100%) */
|
|
17
32
|
pdfPages: import("vue").ShallowRef<ViewerPdfPage[], ViewerPdfPage[]>;
|
|
18
33
|
/** Pages filtered by view mode (for page scroll mode) */
|
|
19
34
|
filteredPages: import("vue").ComputedRef<ViewerPdfPage[]>;
|
|
35
|
+
/** True while this document is laid out from page-1 estimates */
|
|
36
|
+
isLazyMode: import("vue").ShallowRef<boolean, boolean>;
|
|
20
37
|
};
|
|
21
38
|
export default usePdfActualPages;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ComputedRef, type Reactive, type ComponentInternalInstance, type Ref } from 'vue';
|
|
2
2
|
import { type Localization, type PluginItem, type Plugin } from '@vue-pdf-viewer/shared';
|
|
3
3
|
import type { PDFDocumentProxy } from 'pdfjs-dist';
|
|
4
|
-
declare const usePlugins: (instance: ComponentInternalInstance, plugins?: Reactive<Plugin<PDFDocumentProxy>[]>, viewerLocalization?: ComputedRef<Localization>, pdfDocument?: Ref<PDFDocumentProxy | undefined>,
|
|
4
|
+
declare const usePlugins: (instance: ComponentInternalInstance, plugins?: Reactive<Plugin<PDFDocumentProxy>[]>, viewerLocalization?: ComputedRef<Localization>, pdfDocument?: Ref<PDFDocumentProxy | undefined>, getOriginalPdfBytes?: () => Promise<Uint8Array | null>) => {
|
|
5
5
|
sidebarItems: Ref<PluginItem[]>;
|
|
6
6
|
annotationMounted: Ref<boolean>;
|
|
7
7
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { ShallowRef } from 'vue';
|
|
1
|
+
import { Ref, ShallowRef } from 'vue';
|
|
2
2
|
import type { PDFDocumentProxy } from 'pdfjs-dist';
|
|
3
3
|
import type { SearchControlValue, HighlightOptions } from '@/utils/types';
|
|
4
|
-
declare const useSearch: (pdfDoc: ShallowRef<PDFDocumentProxy | undefined>, initialSearch?: string, options?: ShallowRef<HighlightOptions>) => SearchControlValue;
|
|
4
|
+
declare const useSearch: (pdfDoc: ShallowRef<PDFDocumentProxy | undefined>, initialSearch?: string, options?: ShallowRef<HighlightOptions>, currentPage?: Ref<number>) => SearchControlValue;
|
|
5
5
|
export default useSearch;
|
|
@@ -39,6 +39,12 @@ export interface UseVirtualListReturn {
|
|
|
39
39
|
* until the scroll animation settles.
|
|
40
40
|
*/
|
|
41
41
|
isScrollSettling: Ref<boolean>;
|
|
42
|
+
/**
|
|
43
|
+
* True while a programmatic navigation is still converging on its target page, which
|
|
44
|
+
* only happens while the document holds estimated dimensions. The viewer shows a loader
|
|
45
|
+
* instead of pages during this, so intermediate positions are never displayed.
|
|
46
|
+
*/
|
|
47
|
+
isNavigationSettling: Ref<boolean>;
|
|
42
48
|
}
|
|
43
49
|
interface UseVirtualPagesProps {
|
|
44
50
|
pages: Ref<ViewerPdfPage[]>;
|
|
@@ -54,6 +60,11 @@ interface UseVirtualPagesProps {
|
|
|
54
60
|
cancelAllRenders?: () => void;
|
|
55
61
|
reprioritizeCurrentPage?: () => void;
|
|
56
62
|
pageRotationMap?: Ref<Map<number, number>>;
|
|
63
|
+
/**
|
|
64
|
+
* Requests real page data for a page still laid out from an estimate.
|
|
65
|
+
* Fire-and-forget: it never rejects, and the page corrects itself when it resolves.
|
|
66
|
+
*/
|
|
67
|
+
ensurePageLoaded?: (pageIndex: number) => Promise<unknown>;
|
|
57
68
|
}
|
|
58
69
|
/**
|
|
59
70
|
* Composable for virtual scrolling of PDF pages with support for multiple view modes.
|
package/dist/types/const.d.ts
CHANGED
|
@@ -66,6 +66,12 @@ export declare const EMPTY_KEYWORD_REGEXP: NormalizedKeyword;
|
|
|
66
66
|
export declare const CURRENT_MATCH_CSS_CLASS = "vpv-highlight__text-current";
|
|
67
67
|
export declare const LATEST_MATCH_POSITION: InjectionKey<Ref<HighlightMatchPosition | undefined, HighlightMatchPosition | undefined>>;
|
|
68
68
|
export declare const GET_PAGE: InjectionKey<(doc: PDFDocumentProxy, pageIndex: number) => Promise<PDFPageProxy>>;
|
|
69
|
+
/**
|
|
70
|
+
* Requests real page data for a page still laid out from an estimate.
|
|
71
|
+
* Provided by VPdfViewer so surfaces outside the main scroll area — the thumbnail rail,
|
|
72
|
+
* for one — can resolve the pages they show.
|
|
73
|
+
*/
|
|
74
|
+
export declare const ENSURE_PAGE_LOADED: InjectionKey<(pageIndex: number) => Promise<unknown>>;
|
|
69
75
|
export declare const RESTRICTED_CUSTOM: InjectionKey<Ref<boolean, boolean>>;
|
|
70
76
|
export declare const VIEWER_STATE: InjectionKey<{
|
|
71
77
|
pdfDocument: {
|
|
@@ -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>>;
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pure layout arithmetic for the virtualised page list.
|
|
3
|
+
*
|
|
4
|
+
* `useVirtualPages` stacks pages as plain numbers — the unrendered ones never become DOM —
|
|
5
|
+
* so everything about where a page sits reduces to running totals over a size array. That
|
|
6
|
+
* arithmetic lives here so it can be tested directly, and so the scroll-anchoring rules
|
|
7
|
+
* are stated in one place rather than inline among the scroll handlers.
|
|
8
|
+
*
|
|
9
|
+
* Naming follows the React PDF Kit `documentLayout` module, which models the same problem.
|
|
10
|
+
*/
|
|
11
|
+
/** A position in the document expressed relative to content rather than pixels. */
|
|
12
|
+
export interface LayoutAnchor {
|
|
13
|
+
/** Index of the stacking unit (page, row, or column) under the viewport's leading edge. */
|
|
14
|
+
index: number;
|
|
15
|
+
/** Distance into that unit, in BASE-SCALE units so the anchor survives zoom. */
|
|
16
|
+
offset: number;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Running totals of `sizes`, where entry i is the offset of the END of unit i.
|
|
20
|
+
* The start of unit i is therefore `totals[i - 1]`, or 0 for the first unit.
|
|
21
|
+
*/
|
|
22
|
+
export declare function buildCumulativeTotals(sizes: number[]): number[];
|
|
23
|
+
/**
|
|
24
|
+
* Index of the unit containing `position`.
|
|
25
|
+
*
|
|
26
|
+
* Binary search over the running totals. A position past the end clamps to the last unit
|
|
27
|
+
* rather than returning -1, so a scroll beyond the content still anchors to real content.
|
|
28
|
+
*/
|
|
29
|
+
export declare function findUnitAtOffset(totals: number[], position: number): number;
|
|
30
|
+
/** Offset at which unit `index` starts. */
|
|
31
|
+
export declare function getUnitStart(totals: number[], index: number): number;
|
|
32
|
+
/**
|
|
33
|
+
* Converts a pixel scroll position into a content anchor.
|
|
34
|
+
*
|
|
35
|
+
* Dividing by the scale is what makes the anchor survive zoom: the same anchor resolves
|
|
36
|
+
* correctly at any later scale.
|
|
37
|
+
*/
|
|
38
|
+
export declare function captureLayoutAnchor(totals: number[], position: number, scale: number): LayoutAnchor;
|
|
39
|
+
/**
|
|
40
|
+
* Converts a content anchor back into a pixel scroll position against the CURRENT totals.
|
|
41
|
+
*
|
|
42
|
+
* This is the step that absorbs a dimension correction: the unit index still identifies
|
|
43
|
+
* the same content, and its start has moved to wherever the corrected sizes put it.
|
|
44
|
+
* Returns null when there is no layout to resolve against.
|
|
45
|
+
*/
|
|
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;
|
|
@@ -4,6 +4,16 @@ interface MatchWithLines extends Match {
|
|
|
4
4
|
lines?: any[];
|
|
5
5
|
}
|
|
6
6
|
declare function isMatchEntireWord(content: string, startIdx: number, length: number): boolean;
|
|
7
|
+
/**
|
|
8
|
+
* Flattens a page's text content into the single string searches run against.
|
|
9
|
+
*
|
|
10
|
+
* Exported so callers can cache the string per page and re-run queries without holding
|
|
11
|
+
* on to the much larger `TextContent` object. Matching must use *this* string, or the
|
|
12
|
+
* offsets `convertMatches` relies on would not line up.
|
|
13
|
+
*/
|
|
14
|
+
declare function buildSearchText(textContent: TextContent): string;
|
|
15
|
+
/** True if the query occurs at least once in a page string built by `buildSearchText`. */
|
|
16
|
+
declare function hasSearchMatch(text: string, query: string | RegExp, options: HighlightOptions): boolean;
|
|
7
17
|
declare function highlightMatches(matches: Match[], textContent: TextContent, textDivs: HTMLElement[]): void;
|
|
8
18
|
/**
|
|
9
19
|
* Appends highlights without removing existing ones.
|
|
@@ -13,4 +23,4 @@ declare function appendHighlightMatches(matches: Match[], textDivs: HTMLElement[
|
|
|
13
23
|
declare function resetDivs(textContent: TextContent, textDivs: HTMLElement[]): void;
|
|
14
24
|
declare function findMatches(queries: (string | RegExp)[], textContent: TextContent, pageIndex: number, options: HighlightOptions): MatchWithLines[];
|
|
15
25
|
declare function getHighlightOptionsWithDefaults(options?: HighlightOptions): HighlightOptions;
|
|
16
|
-
export { appendHighlightMatches, findMatches, highlightMatches, resetDivs, getHighlightOptionsWithDefaults, isMatchEntireWord };
|
|
26
|
+
export { appendHighlightMatches, buildSearchText, findMatches, hasSearchMatch, highlightMatches, resetDivs, getHighlightOptionsWithDefaults, isMatchEntireWord };
|
|
@@ -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;
|
|
@@ -215,17 +215,31 @@ export interface PdfPageSize {
|
|
|
215
215
|
pageRect: Rect;
|
|
216
216
|
}
|
|
217
217
|
export interface VPVThumbnail {
|
|
218
|
-
page
|
|
218
|
+
/** `null` while the page is still estimated — the thumbnail shows a placeholder. */
|
|
219
|
+
page: PDFPageProxy | null;
|
|
219
220
|
}
|
|
220
221
|
export interface Offset {
|
|
221
222
|
left: number;
|
|
222
223
|
top: number;
|
|
223
224
|
}
|
|
224
225
|
export interface ViewerPdfPage {
|
|
225
|
-
|
|
226
|
+
/**
|
|
227
|
+
* The pdf.js page proxy, or `null` while the page's dimensions are still estimated.
|
|
228
|
+
* NEVER dereference without a guard — use `pageNumber` for identity instead.
|
|
229
|
+
*/
|
|
230
|
+
page: PDFPageProxy | null;
|
|
231
|
+
/** 1-based page number. Always present, including for estimated entries. */
|
|
232
|
+
pageNumber: number;
|
|
226
233
|
viewport: PageViewport;
|
|
227
234
|
height: number;
|
|
228
235
|
width: number;
|
|
236
|
+
/** True until the real page has been fetched and dimensions corrected. */
|
|
237
|
+
isEstimated: boolean;
|
|
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
|
+
*/
|
|
242
|
+
pdfPageRotate: number;
|
|
229
243
|
}
|
|
230
244
|
export interface ItemMeasurement {
|
|
231
245
|
index: number;
|
|
@@ -453,6 +467,8 @@ export interface VPdfViewerProps {
|
|
|
453
467
|
/**
|
|
454
468
|
* A callback function that will be executed after each canvas is loaded.
|
|
455
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.
|
|
456
472
|
*/
|
|
457
473
|
afterCanvasLoaded?: Record<number, CanvasLoadedCallback>;
|
|
458
474
|
/**
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vue-pdf-viewer/viewer",
|
|
3
3
|
"private": false,
|
|
4
|
-
"version": "4.
|
|
4
|
+
"version": "4.5.0-beta.0",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.cjs",
|
|
7
7
|
"module": "./dist/index.js",
|
|
@@ -80,9 +80,10 @@
|
|
|
80
80
|
"vue": "^3.2.37"
|
|
81
81
|
},
|
|
82
82
|
"devDependencies": {
|
|
83
|
-
"@laynezh/vite-plugin-lib-assets": "^0.5.24",
|
|
84
83
|
"@esbuild/darwin-arm64": "0.21.5",
|
|
85
84
|
"@esbuild/darwin-x64": "0.21.5",
|
|
85
|
+
"@laynezh/vite-plugin-lib-assets": "^0.5.24",
|
|
86
|
+
"@rollup/rollup-darwin-arm64": "^4.60.4",
|
|
86
87
|
"@rollup/rollup-darwin-x64": "^4.60.1",
|
|
87
88
|
"@types/node": "^20.11.30",
|
|
88
89
|
"@types/node-forge": "^1.3.14",
|