pdfjs-viewer-element 4.0.1 → 4.1.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pdfjs-viewer-element",
3
- "version": "4.0.1",
3
+ "version": "4.1.0",
4
4
  "license": "MIT",
5
5
  "author": {
6
6
  "name": "Oleksandr Shevchuk",
@@ -28,7 +28,10 @@
28
28
  "types": "types/pdfjs-viewer-element.d.ts",
29
29
  "type": "module",
30
30
  "exports": {
31
- ".": "./dist/pdfjs-viewer-element.js",
31
+ ".": {
32
+ "types": "./types/pdfjs-viewer-element.d.ts",
33
+ "default": "./dist/pdfjs-viewer-element.js"
34
+ },
32
35
  "./dist/*": "./dist/*"
33
36
  },
34
37
  "repository": {
@@ -43,15 +46,6 @@
43
46
  "dist",
44
47
  "types"
45
48
  ],
46
- "scripts": {
47
- "sync:pdfjs": "node scripts/sync-pdfjs-assets.mjs",
48
- "dev": "vite",
49
- "build": "pnpm sync:pdfjs && tsc && vite build && node scripts/copy-worker.mjs",
50
- "test": "pnpm sync:pdfjs && vitest",
51
- "coverage": "pnpm sync:pdfjs && vitest run --coverage",
52
- "release": "node scripts/release.mjs",
53
- "release:dry": "node scripts/release.mjs --dry-run"
54
- },
55
49
  "devDependencies": {
56
50
  "@rollup/plugin-terser": "^1.0.0",
57
51
  "@types/html-minifier-terser": "^7.0.2",
@@ -69,5 +63,14 @@
69
63
  },
70
64
  "dependencies": {
71
65
  "pdfjs-dist": "^6.2.108"
66
+ },
67
+ "scripts": {
68
+ "sync:pdfjs": "node scripts/sync-pdfjs-assets.mjs",
69
+ "dev": "vite",
70
+ "build": "pnpm sync:pdfjs && tsc && vite build && node scripts/copy-worker.mjs",
71
+ "test": "pnpm sync:pdfjs && vitest",
72
+ "coverage": "pnpm sync:pdfjs && vitest run --coverage",
73
+ "release": "node scripts/release.mjs",
74
+ "release:dry": "node scripts/release.mjs --dry-run"
72
75
  }
73
- }
76
+ }
@@ -1,8 +1,24 @@
1
+ import type { DocumentInitParameters } from 'pdfjs-dist/types/src/display/api';
2
+ import type { EventBus } from 'pdfjs-dist/types/web/event_utils';
1
3
  export declare const ViewerCssTheme: {
2
4
  readonly AUTOMATIC: 0;
3
5
  readonly LIGHT: 1;
4
6
  readonly DARK: 2;
5
7
  };
8
+ export type PdfViewerApplicationOpenParameters = (DocumentInitParameters & {
9
+ originalUrl?: string;
10
+ }) | Uint8Array;
11
+ export type PdfViewerApplicationOptionValue = string | boolean | number | Record<string, unknown>;
12
+ export interface PdfViewerApplication {
13
+ initializedPromise: Promise<void>;
14
+ initialized: boolean;
15
+ eventBus: EventBus;
16
+ open: (params: PdfViewerApplicationOpenParameters) => void | Promise<void>;
17
+ }
18
+ export interface PdfViewerApplicationOptions {
19
+ set: (name: string, value: PdfViewerApplicationOptionValue) => void;
20
+ getAll: () => Record<string, unknown>;
21
+ }
6
22
  export declare class PdfjsViewerElement extends HTMLElement {
7
23
  constructor();
8
24
  iframe: PdfjsViewerElementIframe;
@@ -14,6 +30,9 @@ export declare class PdfjsViewerElement extends HTMLElement {
14
30
  static get observedAttributes(): string[];
15
31
  private formatTemplate;
16
32
  private getFullPath;
33
+ private getAssetsBase;
34
+ private getRuntimeFileUrls;
35
+ private getWorkerSrc;
17
36
  private getCssThemeOption;
18
37
  private applyIframeHash;
19
38
  private applyViewerTheme;
@@ -33,34 +52,18 @@ export declare class PdfjsViewerElement extends HTMLElement {
33
52
  disconnectedCallback(): void;
34
53
  attributeChangedCallback(name: string, oldValue: string | null, newValue: string | null): Promise<void>;
35
54
  injectViewerStyles(styles: string): Promise<void>;
36
- setViewerOptions(options?: Record<string, string | number>): Promise<{
37
- viewerOptions: {
38
- set: (name: string, value: string | boolean | number | Record<string, any>) => void;
39
- getAll: () => Record<string, any>;
40
- };
55
+ setViewerOptions(options?: Record<string, PdfViewerApplicationOptionValue>): Promise<{
56
+ viewerOptions: PdfViewerApplicationOptions;
41
57
  }>;
42
58
  }
43
59
  export interface IframeWindow extends Window {
44
- PDFViewerApplication?: {
45
- initializedPromise: Promise<void>;
46
- initialized: boolean;
47
- eventBus: Record<string, any>;
48
- open: (params: {
49
- url: string;
50
- originalUrl?: string;
51
- } | {
52
- data: Uint8Array;
53
- } | Uint8Array) => void;
54
- };
55
- PDFViewerApplicationOptions: {
56
- set: (name: string, value: string | boolean | number | Record<string, any>) => void;
57
- getAll: () => Record<string, any>;
58
- };
60
+ PDFViewerApplication?: PdfViewerApplication;
61
+ PDFViewerApplicationOptions: PdfViewerApplicationOptions;
59
62
  }
60
63
  export interface PdfjsViewerElementIframe extends HTMLIFrameElement {
61
64
  contentWindow: IframeWindow;
62
65
  }
63
66
  export interface InitializationData {
64
- viewerApp?: IframeWindow['PDFViewerApplication'];
67
+ viewerApp?: PdfViewerApplication;
65
68
  }
66
69
  export default PdfjsViewerElement;