@vertexvis/doc-viewer 0.24.5-canary.8
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/LICENSE +21 -0
- package/dist/cjs/doc-viewer.cjs.js +27 -0
- package/dist/cjs/index-DY-_Uhw6.js +1914 -0
- package/dist/cjs/index.cjs.js +5 -0
- package/dist/cjs/loader.cjs.js +15 -0
- package/dist/cjs/vertex-document-viewer.cjs.entry.js +34272 -0
- package/dist/collection/__mocks__/pdfjs-mock.js +33 -0
- package/dist/collection/__setup__/polyfills.js +28 -0
- package/dist/collection/__setup__/resize-observer.js +13 -0
- package/dist/collection/collection-manifest.json +14 -0
- package/dist/collection/components/document-viewer/document-viewer.css +26 -0
- package/dist/collection/components/document-viewer/document-viewer.js +556 -0
- package/dist/collection/index.js +5 -0
- package/dist/collection/lib/config.js +1 -0
- package/dist/collection/lib/document/api.js +97 -0
- package/dist/collection/lib/document/layers/controller.js +41 -0
- package/dist/collection/lib/document/layers/index.js +5 -0
- package/dist/collection/lib/document/layers/types.js +9 -0
- package/dist/collection/lib/document/provider.js +1 -0
- package/dist/collection/lib/document/renderer.js +22 -0
- package/dist/collection/lib/dom.js +6 -0
- package/dist/collection/lib/index.js +4 -0
- package/dist/collection/lib/interactions/pan-interaction-handler.js +67 -0
- package/dist/collection/lib/pdf/pdfjs-api.js +67 -0
- package/dist/collection/lib/pdf/pdfjs-provider.js +12 -0
- package/dist/collection/lib/pdf/pdfjs-renderer.js +77 -0
- package/dist/collection/lib/types/loadableResource.js +18 -0
- package/dist/collection/polyfill/index.js +7 -0
- package/dist/collection/polyfill/resize-observer.js +9 -0
- package/dist/collection/testing/mock-document-api.js +19 -0
- package/dist/components/index.d.ts +35 -0
- package/dist/components/index.js +4 -0
- package/dist/components/p-DRNDkVQa.js +4 -0
- package/dist/components/vertex-document-viewer.d.ts +11 -0
- package/dist/components/vertex-document-viewer.js +39 -0
- package/dist/doc-viewer/doc-viewer.css +1 -0
- package/dist/doc-viewer/doc-viewer.esm.js +4 -0
- package/dist/doc-viewer/index.esm.js +3 -0
- package/dist/doc-viewer/p-Ct6uMP9a.js +5 -0
- package/dist/doc-viewer/p-b8e2846a.entry.js +39 -0
- package/dist/esm/doc-viewer.js +23 -0
- package/dist/esm/index-Ct6uMP9a.js +1886 -0
- package/dist/esm/index.js +3 -0
- package/dist/esm/loader.js +13 -0
- package/dist/esm/vertex-document-viewer.entry.js +34251 -0
- package/dist/index.cjs.js +1 -0
- package/dist/index.js +1 -0
- package/dist/types/__mocks__/pdfjs-mock.d.ts +30 -0
- package/dist/types/__setup__/polyfills.d.ts +1 -0
- package/dist/types/__setup__/resize-observer.d.ts +1 -0
- package/dist/types/components/document-viewer/document-viewer.d.ts +132 -0
- package/dist/types/components.d.ts +176 -0
- package/dist/types/index.d.ts +2 -0
- package/dist/types/lib/config.d.ts +8 -0
- package/dist/types/lib/document/api.d.ts +51 -0
- package/dist/types/lib/document/layers/controller.d.ts +24 -0
- package/dist/types/lib/document/layers/index.d.ts +2 -0
- package/dist/types/lib/document/layers/types.d.ts +15 -0
- package/dist/types/lib/document/provider.d.ts +16 -0
- package/dist/types/lib/document/renderer.d.ts +16 -0
- package/dist/types/lib/dom.d.ts +1 -0
- package/dist/types/lib/index.d.ts +1 -0
- package/dist/types/lib/interactions/pan-interaction-handler.d.ts +16 -0
- package/dist/types/lib/pdf/pdfjs-api.d.ts +19 -0
- package/dist/types/lib/pdf/pdfjs-provider.d.ts +10 -0
- package/dist/types/lib/pdf/pdfjs-renderer.d.ts +11 -0
- package/dist/types/lib/types/loadableResource.d.ts +11 -0
- package/dist/types/polyfill/index.d.ts +1 -0
- package/dist/types/polyfill/resize-observer.d.ts +1 -0
- package/dist/types/stencil-public-runtime.d.ts +1860 -0
- package/dist/types/testing/mock-document-api.d.ts +14 -0
- package/package.json +96 -0
- package/readme.md +17 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
module.exports = require('./cjs/index.cjs.js');
|
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './esm/index.js';
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { PDFDocumentProxy } from 'pdfjs-dist/legacy/build/pdf.mjs';
|
|
2
|
+
export declare class MockOptionalContentConfig extends Map {
|
|
3
|
+
setVisibility: jest.Mock<any, any, any>;
|
|
4
|
+
}
|
|
5
|
+
export declare const mockGetViewport: jest.Mock<{
|
|
6
|
+
width: number;
|
|
7
|
+
height: number;
|
|
8
|
+
}, [], any>;
|
|
9
|
+
export declare const mockPageRender: jest.Mock<{
|
|
10
|
+
promise: Promise<void>;
|
|
11
|
+
}, [], any>;
|
|
12
|
+
export declare const mockGetPage: jest.Mock<{
|
|
13
|
+
getTextContent: jest.Mock<{
|
|
14
|
+
items: never[];
|
|
15
|
+
}, [], any>;
|
|
16
|
+
render: jest.Mock<{
|
|
17
|
+
promise: Promise<void>;
|
|
18
|
+
}, [], any>;
|
|
19
|
+
getViewport: jest.Mock<{
|
|
20
|
+
width: number;
|
|
21
|
+
height: number;
|
|
22
|
+
}, [], any>;
|
|
23
|
+
}, [], any>;
|
|
24
|
+
export declare const mockDestroy: jest.Mock<any, any, any>;
|
|
25
|
+
export declare const mockGetDocument: jest.Mock<any, [], any>;
|
|
26
|
+
export declare const mockPdfDocument: PDFDocumentProxy;
|
|
27
|
+
export declare const GlobalWorkerOptions: {
|
|
28
|
+
workerSrc: string;
|
|
29
|
+
};
|
|
30
|
+
export declare const getDocument: jest.Mock<any, [], any>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import 'abortcontroller-polyfill/dist/polyfill-patch-fetch';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const triggerResizeObserver: jest.Mock<any, any, any>;
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
import { EventEmitter } from '../../stencil-public-runtime';
|
|
2
|
+
import { Point } from '@vertexvis/geometry';
|
|
3
|
+
import { PartialConfig } from '../../lib/config';
|
|
4
|
+
import { DocumentApiState } from '../../lib/document/api';
|
|
5
|
+
import { DocumentLayersController } from '../../lib/document/layers/controller';
|
|
6
|
+
import { DocumentProvider } from '../../lib/document/provider';
|
|
7
|
+
export type InteractionMode = 'none' | 'pan';
|
|
8
|
+
export declare class VertexDocumentViewer {
|
|
9
|
+
/**
|
|
10
|
+
* A URI of the document to load when the component is mounted in the DOM tree.
|
|
11
|
+
* Currently only supports URLs for client-side rendering.
|
|
12
|
+
*/
|
|
13
|
+
src?: string;
|
|
14
|
+
/**
|
|
15
|
+
* The ID of the loaded `Document`. This ID is required to enable persistence of
|
|
16
|
+
* annotations.
|
|
17
|
+
*
|
|
18
|
+
* Note that this is different than a `File` ID within the Vertex Platform, and must
|
|
19
|
+
* be created separately using the `/documents` endpoints.
|
|
20
|
+
* See https://docs.vertex3d.com/ for more details.
|
|
21
|
+
*/
|
|
22
|
+
documentId?: string;
|
|
23
|
+
/**
|
|
24
|
+
* The provider used to create the document API and renderer.
|
|
25
|
+
*/
|
|
26
|
+
provider: DocumentProvider;
|
|
27
|
+
/**
|
|
28
|
+
* The interaction mode for the viewer. When set to `'pan'`, click and drag
|
|
29
|
+
* will pan the document. When set to `'none'`, no pointer interactions
|
|
30
|
+
* are registered.
|
|
31
|
+
*/
|
|
32
|
+
interactionMode: InteractionMode;
|
|
33
|
+
/**
|
|
34
|
+
* Common state of the current document. This value includes information common to all
|
|
35
|
+
* types of documents, including state like zoom percentage, viewport definition, and offsets.
|
|
36
|
+
*/
|
|
37
|
+
documentState?: DocumentApiState;
|
|
38
|
+
/**
|
|
39
|
+
* Controller for interacting with layers in the currently loaded document.
|
|
40
|
+
*
|
|
41
|
+
* This controller will automatically be created along with the loaded document.
|
|
42
|
+
* Note that the methods available on this controller will only be supported if
|
|
43
|
+
* the underlying document type supports layers.
|
|
44
|
+
*/
|
|
45
|
+
layers?: DocumentLayersController;
|
|
46
|
+
/**
|
|
47
|
+
* Configuration values for the document viewer. See {@link Config} for more information
|
|
48
|
+
* on the available configuration options.
|
|
49
|
+
*/
|
|
50
|
+
config?: PartialConfig;
|
|
51
|
+
/**
|
|
52
|
+
* An optional value that will debounce image updates when resizing
|
|
53
|
+
* this viewer element.
|
|
54
|
+
*/
|
|
55
|
+
resizeDebounce: number;
|
|
56
|
+
/**
|
|
57
|
+
* Emits an event when the document is ready to be interacted with.
|
|
58
|
+
*/
|
|
59
|
+
documentReady: EventEmitter<void>;
|
|
60
|
+
/**
|
|
61
|
+
* Emits an event when the document state changes.
|
|
62
|
+
*/
|
|
63
|
+
documentStateChanged: EventEmitter<DocumentApiState>;
|
|
64
|
+
/**
|
|
65
|
+
* Emits an event when a page has been loaded or reloaded prior to being
|
|
66
|
+
* drawn to the canvas.
|
|
67
|
+
*/
|
|
68
|
+
pageLoaded: EventEmitter<DocumentApiState>;
|
|
69
|
+
/**
|
|
70
|
+
* Emits an event when a page has been drawn to the canvas.
|
|
71
|
+
*/
|
|
72
|
+
pageDrawn: EventEmitter<DocumentApiState>;
|
|
73
|
+
private hostEl;
|
|
74
|
+
private viewerContainerElement?;
|
|
75
|
+
private canvasContainerElement?;
|
|
76
|
+
private canvasEl?;
|
|
77
|
+
private dimensions;
|
|
78
|
+
private resizeObserver?;
|
|
79
|
+
private resizeTimer?;
|
|
80
|
+
private documentRenderer?;
|
|
81
|
+
private documentApi?;
|
|
82
|
+
private panInteractionHandler?;
|
|
83
|
+
private documentApiStateChangedDisposable?;
|
|
84
|
+
private pageLoadedDisposable?;
|
|
85
|
+
private pageDrawnDisposable?;
|
|
86
|
+
protected componentWillLoad(): void;
|
|
87
|
+
protected componentShouldUpdate(newValue: unknown, oldValue: unknown, propName: string): boolean;
|
|
88
|
+
protected componentDidLoad(): void;
|
|
89
|
+
protected disconnectedCallback(): void;
|
|
90
|
+
/**
|
|
91
|
+
* Pans the currently loaded document by the specified delta.
|
|
92
|
+
*
|
|
93
|
+
* This method will be bounded to the visible portion of the document to ensure
|
|
94
|
+
* at least a portion of the document is always visible, and the `canvas` does not
|
|
95
|
+
* appear blank.
|
|
96
|
+
*
|
|
97
|
+
* @param delta The delta to pan the document by.
|
|
98
|
+
*/
|
|
99
|
+
panByDelta(delta: Point.Point): Promise<void>;
|
|
100
|
+
/**
|
|
101
|
+
* Zooms the currently loaded document to the specified zoom percentage.
|
|
102
|
+
*
|
|
103
|
+
* This method will automatically adjust existing offsets to maintain the
|
|
104
|
+
* same center point of the document where possible.
|
|
105
|
+
*
|
|
106
|
+
* @param percentage The zoom percentage to set.
|
|
107
|
+
*/
|
|
108
|
+
zoomTo(percentage: number): Promise<void>;
|
|
109
|
+
/**
|
|
110
|
+
* Loads a specific page of the currently loaded document.
|
|
111
|
+
*
|
|
112
|
+
* Note that any offset applied by panning the document will be reset when loading
|
|
113
|
+
* a new page.
|
|
114
|
+
*
|
|
115
|
+
* @param pageNumber The page number to load.
|
|
116
|
+
*/
|
|
117
|
+
loadPage(pageNumber: number): Promise<void>;
|
|
118
|
+
protected handleSrcChange(): Promise<void>;
|
|
119
|
+
protected handleConfigChange(): void;
|
|
120
|
+
protected handleInteractionModeChange(): void;
|
|
121
|
+
render(): void;
|
|
122
|
+
private getDocumentApi;
|
|
123
|
+
private clearCurrentDocument;
|
|
124
|
+
private handleDocumentApiStateChanged;
|
|
125
|
+
private handlePageLoaded;
|
|
126
|
+
private handlePageDrawn;
|
|
127
|
+
private updateDocumentApiListeners;
|
|
128
|
+
private updateInteractionHandler;
|
|
129
|
+
private updateComponentDimensions;
|
|
130
|
+
private handleElementResize;
|
|
131
|
+
private restartResizeTimer;
|
|
132
|
+
}
|
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
/* eslint-disable */
|
|
2
|
+
/* tslint:disable */
|
|
3
|
+
/**
|
|
4
|
+
* This is an autogenerated file created by the Stencil compiler.
|
|
5
|
+
* It contains typing information for all components that exist in this project.
|
|
6
|
+
*/
|
|
7
|
+
import { HTMLStencilElement, JSXBase } from "./stencil-public-runtime";
|
|
8
|
+
import { DocumentProvider } from "./lib/document/provider";
|
|
9
|
+
import { InteractionMode } from "./components/document-viewer/document-viewer";
|
|
10
|
+
import { DocumentApiState } from "./lib/document/api";
|
|
11
|
+
import { DocumentLayersController } from "./lib/document/layers/controller";
|
|
12
|
+
import { PartialConfig } from "./lib/config";
|
|
13
|
+
import { Point } from "@vertexvis/geometry";
|
|
14
|
+
export { DocumentProvider } from "./lib/document/provider";
|
|
15
|
+
export { InteractionMode } from "./components/document-viewer/document-viewer";
|
|
16
|
+
export { DocumentApiState } from "./lib/document/api";
|
|
17
|
+
export { DocumentLayersController } from "./lib/document/layers/controller";
|
|
18
|
+
export { PartialConfig } from "./lib/config";
|
|
19
|
+
export { Point } from "@vertexvis/geometry";
|
|
20
|
+
export namespace Components {
|
|
21
|
+
interface VertexDocumentViewer {
|
|
22
|
+
/**
|
|
23
|
+
* Configuration values for the document viewer. See {@link Config } for more information on the available configuration options.
|
|
24
|
+
*/
|
|
25
|
+
"config"?: PartialConfig;
|
|
26
|
+
/**
|
|
27
|
+
* The ID of the loaded `Document`. This ID is required to enable persistence of annotations. Note that this is different than a `File` ID within the Vertex Platform, and must be created separately using the `/documents` endpoints. See https://docs.vertex3d.com/ for more details.
|
|
28
|
+
*/
|
|
29
|
+
"documentId"?: string;
|
|
30
|
+
/**
|
|
31
|
+
* Common state of the current document. This value includes information common to all types of documents, including state like zoom percentage, viewport definition, and offsets.
|
|
32
|
+
*/
|
|
33
|
+
"documentState"?: DocumentApiState;
|
|
34
|
+
/**
|
|
35
|
+
* The interaction mode for the viewer. When set to `'pan'`, click and drag will pan the document. When set to `'none'`, no pointer interactions are registered.
|
|
36
|
+
* @default 'pan'
|
|
37
|
+
*/
|
|
38
|
+
"interactionMode": InteractionMode;
|
|
39
|
+
/**
|
|
40
|
+
* Controller for interacting with layers in the currently loaded document. This controller will automatically be created along with the loaded document. Note that the methods available on this controller will only be supported if the underlying document type supports layers.
|
|
41
|
+
*/
|
|
42
|
+
"layers"?: DocumentLayersController;
|
|
43
|
+
/**
|
|
44
|
+
* Loads a specific page of the currently loaded document. Note that any offset applied by panning the document will be reset when loading a new page.
|
|
45
|
+
* @param pageNumber The page number to load.
|
|
46
|
+
*/
|
|
47
|
+
"loadPage": (pageNumber: number) => Promise<void>;
|
|
48
|
+
/**
|
|
49
|
+
* Pans the currently loaded document by the specified delta. This method will be bounded to the visible portion of the document to ensure at least a portion of the document is always visible, and the `canvas` does not appear blank.
|
|
50
|
+
* @param delta The delta to pan the document by.
|
|
51
|
+
*/
|
|
52
|
+
"panByDelta": (delta: Point.Point) => Promise<void>;
|
|
53
|
+
/**
|
|
54
|
+
* The provider used to create the document API and renderer.
|
|
55
|
+
* @default new PdfJsProvider()
|
|
56
|
+
*/
|
|
57
|
+
"provider": DocumentProvider;
|
|
58
|
+
/**
|
|
59
|
+
* An optional value that will debounce image updates when resizing this viewer element.
|
|
60
|
+
* @default 100
|
|
61
|
+
*/
|
|
62
|
+
"resizeDebounce": number;
|
|
63
|
+
/**
|
|
64
|
+
* A URI of the document to load when the component is mounted in the DOM tree. Currently only supports URLs for client-side rendering.
|
|
65
|
+
*/
|
|
66
|
+
"src"?: string;
|
|
67
|
+
/**
|
|
68
|
+
* Zooms the currently loaded document to the specified zoom percentage. This method will automatically adjust existing offsets to maintain the same center point of the document where possible.
|
|
69
|
+
* @param percentage The zoom percentage to set.
|
|
70
|
+
*/
|
|
71
|
+
"zoomTo": (percentage: number) => Promise<void>;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
export interface VertexDocumentViewerCustomEvent<T> extends CustomEvent<T> {
|
|
75
|
+
detail: T;
|
|
76
|
+
target: HTMLVertexDocumentViewerElement;
|
|
77
|
+
}
|
|
78
|
+
declare global {
|
|
79
|
+
interface HTMLVertexDocumentViewerElementEventMap {
|
|
80
|
+
"documentReady": void;
|
|
81
|
+
"documentStateChanged": DocumentApiState;
|
|
82
|
+
"pageLoaded": DocumentApiState;
|
|
83
|
+
"pageDrawn": DocumentApiState;
|
|
84
|
+
}
|
|
85
|
+
interface HTMLVertexDocumentViewerElement extends Components.VertexDocumentViewer, HTMLStencilElement {
|
|
86
|
+
addEventListener<K extends keyof HTMLVertexDocumentViewerElementEventMap>(type: K, listener: (this: HTMLVertexDocumentViewerElement, ev: VertexDocumentViewerCustomEvent<HTMLVertexDocumentViewerElementEventMap[K]>) => any, options?: boolean | AddEventListenerOptions): void;
|
|
87
|
+
addEventListener<K extends keyof DocumentEventMap>(type: K, listener: (this: Document, ev: DocumentEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
|
|
88
|
+
addEventListener<K extends keyof HTMLElementEventMap>(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
|
|
89
|
+
addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void;
|
|
90
|
+
removeEventListener<K extends keyof HTMLVertexDocumentViewerElementEventMap>(type: K, listener: (this: HTMLVertexDocumentViewerElement, ev: VertexDocumentViewerCustomEvent<HTMLVertexDocumentViewerElementEventMap[K]>) => any, options?: boolean | EventListenerOptions): void;
|
|
91
|
+
removeEventListener<K extends keyof DocumentEventMap>(type: K, listener: (this: Document, ev: DocumentEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
|
|
92
|
+
removeEventListener<K extends keyof HTMLElementEventMap>(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
|
|
93
|
+
removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void;
|
|
94
|
+
}
|
|
95
|
+
var HTMLVertexDocumentViewerElement: {
|
|
96
|
+
prototype: HTMLVertexDocumentViewerElement;
|
|
97
|
+
new (): HTMLVertexDocumentViewerElement;
|
|
98
|
+
};
|
|
99
|
+
interface HTMLElementTagNameMap {
|
|
100
|
+
"vertex-document-viewer": HTMLVertexDocumentViewerElement;
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
declare namespace LocalJSX {
|
|
104
|
+
interface VertexDocumentViewer {
|
|
105
|
+
/**
|
|
106
|
+
* Configuration values for the document viewer. See {@link Config } for more information on the available configuration options.
|
|
107
|
+
*/
|
|
108
|
+
"config"?: PartialConfig;
|
|
109
|
+
/**
|
|
110
|
+
* The ID of the loaded `Document`. This ID is required to enable persistence of annotations. Note that this is different than a `File` ID within the Vertex Platform, and must be created separately using the `/documents` endpoints. See https://docs.vertex3d.com/ for more details.
|
|
111
|
+
*/
|
|
112
|
+
"documentId"?: string;
|
|
113
|
+
/**
|
|
114
|
+
* Common state of the current document. This value includes information common to all types of documents, including state like zoom percentage, viewport definition, and offsets.
|
|
115
|
+
*/
|
|
116
|
+
"documentState"?: DocumentApiState;
|
|
117
|
+
/**
|
|
118
|
+
* The interaction mode for the viewer. When set to `'pan'`, click and drag will pan the document. When set to `'none'`, no pointer interactions are registered.
|
|
119
|
+
* @default 'pan'
|
|
120
|
+
*/
|
|
121
|
+
"interactionMode"?: InteractionMode;
|
|
122
|
+
/**
|
|
123
|
+
* Controller for interacting with layers in the currently loaded document. This controller will automatically be created along with the loaded document. Note that the methods available on this controller will only be supported if the underlying document type supports layers.
|
|
124
|
+
*/
|
|
125
|
+
"layers"?: DocumentLayersController;
|
|
126
|
+
/**
|
|
127
|
+
* Emits an event when the document is ready to be interacted with.
|
|
128
|
+
*/
|
|
129
|
+
"onDocumentReady"?: (event: VertexDocumentViewerCustomEvent<void>) => void;
|
|
130
|
+
/**
|
|
131
|
+
* Emits an event when the document state changes.
|
|
132
|
+
*/
|
|
133
|
+
"onDocumentStateChanged"?: (event: VertexDocumentViewerCustomEvent<DocumentApiState>) => void;
|
|
134
|
+
/**
|
|
135
|
+
* Emits an event when a page has been drawn to the canvas.
|
|
136
|
+
*/
|
|
137
|
+
"onPageDrawn"?: (event: VertexDocumentViewerCustomEvent<DocumentApiState>) => void;
|
|
138
|
+
/**
|
|
139
|
+
* Emits an event when a page has been loaded or reloaded prior to being drawn to the canvas.
|
|
140
|
+
*/
|
|
141
|
+
"onPageLoaded"?: (event: VertexDocumentViewerCustomEvent<DocumentApiState>) => void;
|
|
142
|
+
/**
|
|
143
|
+
* The provider used to create the document API and renderer.
|
|
144
|
+
* @default new PdfJsProvider()
|
|
145
|
+
*/
|
|
146
|
+
"provider"?: DocumentProvider;
|
|
147
|
+
/**
|
|
148
|
+
* An optional value that will debounce image updates when resizing this viewer element.
|
|
149
|
+
* @default 100
|
|
150
|
+
*/
|
|
151
|
+
"resizeDebounce"?: number;
|
|
152
|
+
/**
|
|
153
|
+
* A URI of the document to load when the component is mounted in the DOM tree. Currently only supports URLs for client-side rendering.
|
|
154
|
+
*/
|
|
155
|
+
"src"?: string;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
interface VertexDocumentViewerAttributes {
|
|
159
|
+
"src": string;
|
|
160
|
+
"documentId": string;
|
|
161
|
+
"interactionMode": InteractionMode;
|
|
162
|
+
"resizeDebounce": number;
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
interface IntrinsicElements {
|
|
166
|
+
"vertex-document-viewer": Omit<VertexDocumentViewer, keyof VertexDocumentViewerAttributes> & { [K in keyof VertexDocumentViewer & keyof VertexDocumentViewerAttributes]?: VertexDocumentViewer[K] } & { [K in keyof VertexDocumentViewer & keyof VertexDocumentViewerAttributes as `attr:${K}`]?: VertexDocumentViewerAttributes[K] } & { [K in keyof VertexDocumentViewer & keyof VertexDocumentViewerAttributes as `prop:${K}`]?: VertexDocumentViewer[K] };
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
export { LocalJSX as JSX };
|
|
170
|
+
declare module "@stencil/core" {
|
|
171
|
+
export namespace JSX {
|
|
172
|
+
interface IntrinsicElements {
|
|
173
|
+
"vertex-document-viewer": LocalJSX.IntrinsicElements["vertex-document-viewer"] & JSXBase.HTMLAttributes<HTMLVertexDocumentViewerElement>;
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { Dimensions, Point } from '@vertexvis/geometry';
|
|
2
|
+
import { Disposable, EventDispatcher, Listener } from '@vertexvis/utils';
|
|
3
|
+
export declare const MAX_ZOOM_PERCENTAGE = 600;
|
|
4
|
+
export declare const MIN_ZOOM_PERCENTAGE = 10;
|
|
5
|
+
export interface DocumentApiState {
|
|
6
|
+
readonly zoomPercentage: number;
|
|
7
|
+
readonly viewport?: Dimensions.Dimensions;
|
|
8
|
+
readonly contentDimensions?: Dimensions.Dimensions;
|
|
9
|
+
readonly panOffset: Point.Point;
|
|
10
|
+
readonly loadedPageNumber?: number;
|
|
11
|
+
readonly totalPageCount?: number;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Base class for all document APIs. This class provides implementations for
|
|
15
|
+
* operations common to all document types, such as viewport changes and loading
|
|
16
|
+
* of pages.
|
|
17
|
+
*/
|
|
18
|
+
export declare abstract class DocumentApi<T extends DocumentApiState = DocumentApiState> {
|
|
19
|
+
protected readonly defaultState: T;
|
|
20
|
+
protected state: T;
|
|
21
|
+
protected readonly stateChanged: EventDispatcher<T>;
|
|
22
|
+
constructor(defaultState: T);
|
|
23
|
+
protected updateState(state: Partial<T>): void;
|
|
24
|
+
onStateChanged(listener: Listener<T>): Disposable;
|
|
25
|
+
updateViewport(viewport: Dimensions.Dimensions): Promise<void>;
|
|
26
|
+
/**
|
|
27
|
+
* Updates the pan offset for this API, and emits new state with the updated
|
|
28
|
+
* offset.
|
|
29
|
+
*
|
|
30
|
+
* This method will be bounded to the visible portion of the document to ensure
|
|
31
|
+
* at least a portion of the document is always visible, and the `canvas` does not
|
|
32
|
+
* appear blank.
|
|
33
|
+
*
|
|
34
|
+
* @param delta The delta to pan the document by.
|
|
35
|
+
*/
|
|
36
|
+
panByDelta(delta: Point.Point): Promise<void>;
|
|
37
|
+
/**
|
|
38
|
+
* Updates the zoom percentage for this API, and emits new state with the updated
|
|
39
|
+
* percentage and adjusted pan offset.
|
|
40
|
+
*
|
|
41
|
+
* This method will automatically adjust existing offsets to maintain the
|
|
42
|
+
* same center point of the document where possible.
|
|
43
|
+
*
|
|
44
|
+
* @param percentage The zoom percentage to set.
|
|
45
|
+
*/
|
|
46
|
+
zoomTo(percentage: number): Promise<void>;
|
|
47
|
+
private constrainPanOffset;
|
|
48
|
+
abstract dispose(): void;
|
|
49
|
+
abstract load(uri: string): Promise<void>;
|
|
50
|
+
abstract loadPage(pageNumber: number): Promise<void>;
|
|
51
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { DocumentApi } from '../api';
|
|
2
|
+
import { DocumentLayer } from './types';
|
|
3
|
+
export declare class DocumentLayersController {
|
|
4
|
+
private apiSupportsLayers;
|
|
5
|
+
private api?;
|
|
6
|
+
constructor(api: DocumentApi);
|
|
7
|
+
/**
|
|
8
|
+
* Returns a boolean indicating whether the document supports layers.
|
|
9
|
+
*/
|
|
10
|
+
get enabled(): boolean;
|
|
11
|
+
/**
|
|
12
|
+
* Retrieves the layers of the document.
|
|
13
|
+
*
|
|
14
|
+
* @throws {Error} if the loaded document does not support layers.
|
|
15
|
+
*/
|
|
16
|
+
getLayers(): Promise<DocumentLayer[]>;
|
|
17
|
+
/**
|
|
18
|
+
* Sets the visibility of a layer by ID.
|
|
19
|
+
*
|
|
20
|
+
* @throws {Error} if the loaded document does not support layers.
|
|
21
|
+
*/
|
|
22
|
+
setLayerVisibility(id: string, visible: boolean): Promise<void>;
|
|
23
|
+
private getApi;
|
|
24
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { DocumentApi } from '../api';
|
|
2
|
+
export interface DocumentLayer {
|
|
3
|
+
readonly id: string;
|
|
4
|
+
readonly name: string;
|
|
5
|
+
readonly visible: boolean;
|
|
6
|
+
}
|
|
7
|
+
export interface LayerSupport {
|
|
8
|
+
readonly getLayers: () => DocumentLayer[] | Promise<DocumentLayer[]>;
|
|
9
|
+
readonly setLayerVisibility: (id: string, visible: boolean) => void | Promise<void>;
|
|
10
|
+
}
|
|
11
|
+
export type LayerSupportedApi = DocumentApi & LayerSupport;
|
|
12
|
+
/**
|
|
13
|
+
* Returns a boolean indicating whether the provided document API supports layers.
|
|
14
|
+
*/
|
|
15
|
+
export declare function apiSupportsLayers(api: DocumentApi): api is LayerSupportedApi;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { Config } from '../config';
|
|
2
|
+
import { DocumentApi } from './api';
|
|
3
|
+
import { DocumentRenderer } from './renderer';
|
|
4
|
+
export interface DocumentInterface {
|
|
5
|
+
readonly api: DocumentApi;
|
|
6
|
+
readonly renderer: DocumentRenderer;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* A provider that is responsible for creating an interface for a document. This
|
|
10
|
+
* interface is expected to create a `DocumentApi` and a `DocumentRenderer`, which
|
|
11
|
+
* can be used to perform operations against the document and visualize the resulting
|
|
12
|
+
* image on the provided canvas element.
|
|
13
|
+
*/
|
|
14
|
+
export interface DocumentProvider {
|
|
15
|
+
create(canvas: HTMLCanvasElement, config?: Config): DocumentInterface;
|
|
16
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { Disposable, EventDispatcher, Listener } from '@vertexvis/utils';
|
|
2
|
+
import { DocumentApi, DocumentApiState } from './api';
|
|
3
|
+
/**
|
|
4
|
+
* A renderer that is responsible for listening to state changes in a `DocumentApi`
|
|
5
|
+
* and rendering resulting images to the provided canvas element.
|
|
6
|
+
*/
|
|
7
|
+
export declare abstract class DocumentRenderer implements Disposable {
|
|
8
|
+
protected readonly api: DocumentApi;
|
|
9
|
+
protected readonly canvas: HTMLCanvasElement;
|
|
10
|
+
protected readonly pageLoaded: EventDispatcher<DocumentApiState>;
|
|
11
|
+
protected readonly pageDrawn: EventDispatcher<DocumentApiState>;
|
|
12
|
+
constructor(api: DocumentApi, canvas: HTMLCanvasElement);
|
|
13
|
+
onPageLoaded(listener: Listener<DocumentApiState>): Disposable;
|
|
14
|
+
onPageDrawn(listener: Listener<DocumentApiState>): Disposable;
|
|
15
|
+
abstract dispose(): void | Promise<void>;
|
|
16
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function getElementBoundingClientRect(element: HTMLElement): ClientRect;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './config';
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { Disposable } from '@vertexvis/utils';
|
|
2
|
+
import { DocumentApi } from '../document/api';
|
|
3
|
+
export declare class PanInteractionHandler implements Disposable {
|
|
4
|
+
private element;
|
|
5
|
+
private api;
|
|
6
|
+
private lastPosition?;
|
|
7
|
+
private isDragging;
|
|
8
|
+
private downPosition?;
|
|
9
|
+
constructor(element: HTMLElement, api: DocumentApi);
|
|
10
|
+
dispose(): void;
|
|
11
|
+
private handleWheel;
|
|
12
|
+
private handlePointerDown;
|
|
13
|
+
private handlePointerMove;
|
|
14
|
+
private handlePointerUp;
|
|
15
|
+
private removeWindowListeners;
|
|
16
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import * as pdfjs from 'pdfjs-dist/legacy/build/pdf.mjs';
|
|
2
|
+
import type { OptionalContentConfig } from 'pdfjs-dist/types/src/display/optional_content_config.d.js';
|
|
3
|
+
import { Config } from '../config';
|
|
4
|
+
import { DocumentApi, DocumentApiState } from '../document/api';
|
|
5
|
+
import { DocumentLayer, LayerSupport } from '../document/layers';
|
|
6
|
+
export interface PdfJsApiState extends DocumentApiState {
|
|
7
|
+
readonly document?: pdfjs.PDFDocumentProxy;
|
|
8
|
+
readonly optionalContentConfig?: OptionalContentConfig;
|
|
9
|
+
readonly layers?: DocumentLayer[];
|
|
10
|
+
}
|
|
11
|
+
export declare class PdfJsApi extends DocumentApi<PdfJsApiState> implements LayerSupport {
|
|
12
|
+
private readonly config?;
|
|
13
|
+
constructor(config?: Config | undefined);
|
|
14
|
+
dispose(): void;
|
|
15
|
+
load(uri: string): Promise<void>;
|
|
16
|
+
loadPage(pageNumber: number): Promise<void>;
|
|
17
|
+
getLayers(): DocumentLayer[];
|
|
18
|
+
setLayerVisibility(id: string, visible: boolean): void;
|
|
19
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Config } from '../config';
|
|
2
|
+
import { DocumentApi } from '../document/api';
|
|
3
|
+
import { DocumentProvider } from '../document/provider';
|
|
4
|
+
import { DocumentRenderer } from '../document/renderer';
|
|
5
|
+
export declare class PdfJsProvider implements DocumentProvider {
|
|
6
|
+
create(canvas: HTMLCanvasElement, config?: Config): {
|
|
7
|
+
api: DocumentApi;
|
|
8
|
+
renderer: DocumentRenderer;
|
|
9
|
+
};
|
|
10
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { DocumentRenderer } from '../document/renderer';
|
|
2
|
+
import { PdfJsApi } from './pdfjs-api';
|
|
3
|
+
export declare class PdfJsRenderer extends DocumentRenderer {
|
|
4
|
+
private stateChangedDisposable;
|
|
5
|
+
private state;
|
|
6
|
+
private offscreenCanvas;
|
|
7
|
+
constructor(api: PdfJsApi, canvas: HTMLCanvasElement);
|
|
8
|
+
dispose(): void;
|
|
9
|
+
private handleStateChanged;
|
|
10
|
+
private renderPage;
|
|
11
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
interface UrlResource {
|
|
2
|
+
type: 'url';
|
|
3
|
+
url: string;
|
|
4
|
+
}
|
|
5
|
+
export type LoadableResource = UrlResource;
|
|
6
|
+
export interface Resource {
|
|
7
|
+
resource: LoadableResource;
|
|
8
|
+
}
|
|
9
|
+
export declare function fromUri(uri: string): Resource;
|
|
10
|
+
export declare function fromUrl(url: string): Resource;
|
|
11
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function (): void;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function (): void;
|