@vue-pdf-viewer/viewer 0.0.0-experimental.87 → 0.0.0-experimental.89

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.
Files changed (30) hide show
  1. package/dist/{VPdfViewer.vue_vue_type_style_index_1_scoped_7d8b83ba_lang-Bfjy2H8f.js → VPdfViewer.vue_vue_type_style_index_1_scoped_1a52033e_lang-CueFq_Xb.js} +2737 -2283
  2. package/dist/VPdfViewer.vue_vue_type_style_index_1_scoped_1a52033e_lang-DnmLNDYR.cjs +48 -0
  3. package/dist/annotation-popup-BxZPusRx.js +23 -0
  4. package/dist/annotation-popup-BxlwGOD0.cjs +1 -0
  5. package/dist/{index-CiGWa9Zy.js → index-BDGVwfde.js} +1 -1
  6. package/dist/index-CG0Wg4A5.cjs +27 -0
  7. package/dist/index.cjs +25 -18
  8. package/dist/index.js +10999 -10459
  9. package/dist/license.cjs +1 -1
  10. package/dist/license.js +4 -4
  11. package/dist/types/components/LayerCanvas.vue.d.ts +1 -0
  12. package/dist/types/components/VPdfPagesList.vue.d.ts +133 -0
  13. package/dist/types/components/VPdfViewer.vue.d.ts +131 -7
  14. package/dist/types/components/ui/popover/PopoverContent.vue.d.ts +3 -3
  15. package/dist/types/composables/useAnnotationFreeText.d.ts +5 -0
  16. package/dist/types/composables/useAnnotationHighlight.d.ts +4 -0
  17. package/dist/types/composables/useAnnotationStamp.d.ts +5 -0
  18. package/dist/types/composables/useAnnotationStorage.d.ts +7 -1
  19. package/dist/types/composables/useAnnotationStrikethrough.d.ts +6 -0
  20. package/dist/types/composables/useAnnotationUnderline.d.ts +6 -0
  21. package/dist/types/composables/usePdf.d.ts +1 -1
  22. package/dist/types/composables/useVirtualPages.d.ts +14 -0
  23. package/dist/types/const.d.ts +4 -0
  24. package/dist/types/index.d.ts +2 -2
  25. package/dist/types/utils/annotation-highlight.d.ts +13 -0
  26. package/dist/types/utils/types.d.ts +37 -3
  27. package/dist/types/utils/zoomStretch.d.ts +37 -0
  28. package/package.json +4 -3
  29. package/dist/VPdfViewer.vue_vue_type_style_index_1_scoped_7d8b83ba_lang-BX1zgJnI.cjs +0 -48
  30. package/dist/index-De5RZh9w.cjs +0 -27
@@ -36,6 +36,19 @@ export declare function quadPointsToBoxesForRect(quadPoints: number[], rect: num
36
36
  width: number;
37
37
  height: number;
38
38
  }[];
39
+ /**
40
+ * Reconstruct PDF-coordinate highlight `outlines` from `quadPoints` + `rect`.
41
+ *
42
+ * PDF.js's print/appearance generator (HighlightAnnotation.createNewAppearanceStream)
43
+ * iterates the `outlines` field; a highlight without it throws "n is not iterable",
44
+ * blanking the whole print preview. Highlights imported from XFDF carry only
45
+ * `quadPoints`, so this rebuilds the missing `outlines` using the same outline
46
+ * machinery as tool-created highlights — but normalized against the rect, so no live
47
+ * viewport/DOM is required (safe to call from the print path).
48
+ *
49
+ * @returns serialized outlines (array of point arrays in PDF coords), or null if input is unusable.
50
+ */
51
+ export declare function buildHighlightOutlines(quadPoints: ArrayLike<number> | null | undefined, rect: ArrayLike<number> | null | undefined): number[][] | null;
39
52
  /**
40
53
  * Get selection boxes from text layer with proper rotation handling.
41
54
  * Adapted from PDF.js display/editor/tools.js
@@ -2,7 +2,7 @@ import { ComputedRef, MaybeRef, PropType, Reactive, Ref } from 'vue';
2
2
  import type { PageViewport, RenderTask } from 'pdfjs-dist';
3
3
  import type { DocumentInitParameters, OnProgressParameters, PDFDataRangeTransport, TextContent, TypedArray, PDFPageProxy, PDFDocumentProxy, RenderParameters } from 'pdfjs-dist/types/src/display/api';
4
4
  import type { Metadata } from 'pdfjs-dist/types/src/display/metadata';
5
- import type { Annotation, AnnotationToolOption, TextSelectionOption } from '@vue-pdf-viewer/shared';
5
+ import type { Annotation, AnnotationToolOption, TextSelectionOption, AnnotationTextSelectionControl, AnnotationFreeTextControl, XfdfImportResult, XfdfSkippedEntry } from '@vue-pdf-viewer/shared';
6
6
  import { ZoomLevel, ViewMode, ScrollMode, SelectionMode, VPVAnnotationType, LicenseType, LicenseProduct } from './enumerators';
7
7
  import { Localization, Plugin, AnnotationType } from '@vue-pdf-viewer/shared';
8
8
  export interface VirtualRange {
@@ -122,7 +122,8 @@ export type UpdatePasswordFn = (newPassword: string) => void;
122
122
  export type OnPasswordCallback = (updatePassword: UpdatePasswordFn, reason: any) => void;
123
123
  export type OnErrorCallback = (error: any) => void;
124
124
  export declare enum ErrorType {
125
- NOT_SUPPORTED = "not-supported"
125
+ NOT_SUPPORTED = "not-supported",
126
+ PASSWORD_REQUIRED = "password-required"
126
127
  }
127
128
  /**
128
129
  * Payload for the password-required event.
@@ -184,7 +185,7 @@ export interface PDFOptions {
184
185
  password?: string;
185
186
  }
186
187
  export interface PDFInfoMetadata {
187
- info: Object;
188
+ info: Record<string, any>;
188
189
  metadata: Metadata;
189
190
  }
190
191
  export interface PDFInfo {
@@ -230,6 +231,12 @@ export interface ViewerPdfPage {
230
231
  isEstimated: boolean;
231
232
  /** Inherent page rotation (0, 90, 180, 270). Cloned from page 1 when estimated; set to pdfPage.rotate when actual. */
232
233
  pdfPageRotate: number;
234
+ /**
235
+ * 1-indexed page number this entry represents. Unlike `page.pageNumber`, always
236
+ * available — estimated pages have `page: null`, so consumers must not derive
237
+ * the page index from the proxy.
238
+ */
239
+ pageNumber: number;
233
240
  }
234
241
  export interface ItemMeasurement {
235
242
  index: number;
@@ -383,6 +390,11 @@ export interface VPdfViewerProps {
383
390
  * If unspecified, the viewer will use the worker from pdfjs-dist@3.11.174
384
391
  */
385
392
  workerUrl?: string;
393
+ /**
394
+ * The URL directory where the pdf.js WASM files are located. Include the trailing slash.
395
+ * Required when hosting WASM assets at a custom path (e.g. for JPEG 2000 decoding).
396
+ */
397
+ wasmUrl?: string;
386
398
  /**
387
399
  * The number of page that will be displayed initially
388
400
  */
@@ -507,6 +519,10 @@ export declare const VPVBaseProps: {
507
519
  readonly type: PropType<string>;
508
520
  readonly default: undefined;
509
521
  };
522
+ readonly wasmUrl: {
523
+ readonly type: PropType<string>;
524
+ readonly default: undefined;
525
+ };
510
526
  readonly initialPage: {
511
527
  readonly type: PropType<number>;
512
528
  readonly default: () => number;
@@ -675,6 +691,7 @@ export interface PageControl {
675
691
  goToPage: (page: number) => void;
676
692
  currentPage: number;
677
693
  totalPages: number;
694
+ rotatePage: (pageNumber: number, degree: 90 | 180 | 270 | -90 | ((currentDegree: number) => 90 | 180 | 270 | -90)) => void;
678
695
  }
679
696
  export interface DownloadPdfProgress {
680
697
  bytesDownloaded: number;
@@ -702,6 +719,19 @@ export interface UseScaleCallback {
702
719
  mode?: ZoomLevel;
703
720
  error?: string;
704
721
  }
722
+ export interface XfdfExportOptions {
723
+ pdfFilename?: string;
724
+ download?: boolean;
725
+ }
726
+ export interface AnnotationXfdfControl {
727
+ exportToXfdf: (options?: XfdfExportOptions) => Promise<string>;
728
+ importFromXfdf: (xfdfString: string) => XfdfImportResult;
729
+ }
730
+ export interface AnnotationControl {
731
+ getAnnotations: () => Annotation[];
732
+ clearAnnotations: () => void;
733
+ }
734
+ export type { XfdfImportResult, XfdfSkippedEntry };
705
735
  export interface VPVInstance {
706
736
  printControl: Reactive<PrintControl> | undefined;
707
737
  searchControl: SearchControl | undefined;
@@ -710,6 +740,10 @@ export interface VPVInstance {
710
740
  downloadControl: Reactive<DownloadControl> | undefined;
711
741
  zoomControl: Reactive<ZoomControl> | undefined;
712
742
  passwordControl: Reactive<PasswordControl> | undefined;
743
+ annotationTextSelectionControl: Reactive<AnnotationTextSelectionControl> | undefined;
744
+ annotationFreeTextControl: Reactive<AnnotationFreeTextControl> | undefined;
745
+ annotationXfdfControl: Reactive<AnnotationXfdfControl> | undefined;
746
+ annotationControl: Reactive<AnnotationControl> | undefined;
713
747
  }
714
748
  export interface NavigationAnnotation {
715
749
  action: 'FirstPage' | 'LastPage' | 'NextPage' | 'PrevPage';
@@ -0,0 +1,37 @@
1
+ /**
2
+ * Composited zoom-stretch helpers.
3
+ *
4
+ * During a zoom gesture the DOM layout stays frozen at the gesture-start scale
5
+ * (`baseScale`) and visual feedback comes from a single composited
6
+ * `transform: scale()` on the pages wrapper — a ~3ms compositor operation instead
7
+ * of a style-recalc + layout across every page placeholder (O(N) per zoom step,
8
+ * ~1s main-thread block on a 6000-page document). The real layout is committed
9
+ * once when the gesture settles.
10
+ */
11
+ import type { CSSProperties } from 'vue';
12
+ export type StretchTransformStyle = Pick<CSSProperties, 'transform' | 'transformOrigin' | 'willChange'>;
13
+ /**
14
+ * Compute the wrapper transform that visually stretches the frozen layout from
15
+ * `baseScale` to `currentScale`, anchored so the content point under `origin`
16
+ * (viewport coordinates, relative to the scroll container) stays stationary.
17
+ *
18
+ * @param currentScale - The scale the gesture has reached
19
+ * @param baseScale - The scale the DOM layout is committed at (gesture start)
20
+ * @param origin - Zoom anchor in container-viewport coordinates, or null for the top-left
21
+ * @param baseScroll - Scroll offsets captured at gesture start (layout is frozen, so these stay valid)
22
+ * @param fit - Frozen-scale page size + container inner size. Used to decide PER AXIS whether
23
+ * the page fits at the current gesture scale: on an axis where it fits, that axis cannot
24
+ * scroll and the committed layout keeps the page centered, so the transform scales about the
25
+ * viewport CENTER on that axis (page grows centered, no left/right shift) instead of the
26
+ * cursor. Omit to always cursor-anchor both axes.
27
+ * @returns Style properties for the wrapper, or null when no transform is needed
28
+ */
29
+ export declare function computeStretchTransform(currentScale: number, baseScale: number, origin: [number, number] | null, baseScroll: {
30
+ top: number;
31
+ left: number;
32
+ }, fit?: {
33
+ pageWidth: number;
34
+ pageHeight: number;
35
+ containerWidth: number;
36
+ containerHeight: number;
37
+ } | null): StretchTransformStyle | null;
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.87",
4
+ "version": "0.0.0-experimental.89",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",
7
7
  "module": "./dist/index.js",
@@ -65,7 +65,7 @@
65
65
  "prepare": "husky"
66
66
  },
67
67
  "dependencies": {
68
- "@vue-pdf-viewer/shared": "1.4.0",
68
+ "@vue-pdf-viewer/shared": "1.6.1",
69
69
  "@vueuse/core": "^13.6.0",
70
70
  "node-forge": "^1.3.2",
71
71
  "pdfjs-dist": "5.4.530",
@@ -77,9 +77,10 @@
77
77
  "vue": "^3.2.37"
78
78
  },
79
79
  "devDependencies": {
80
- "@laynezh/vite-plugin-lib-assets": "^0.5.24",
81
80
  "@esbuild/darwin-arm64": "0.21.5",
82
81
  "@esbuild/darwin-x64": "0.21.5",
82
+ "@laynezh/vite-plugin-lib-assets": "^0.5.24",
83
+ "@rollup/rollup-darwin-arm64": "^4.60.4",
83
84
  "@rollup/rollup-darwin-x64": "^4.60.1",
84
85
  "@types/node": "^20.11.30",
85
86
  "@types/node-forge": "^1.3.14",