@vaadin-component-factory/vcf-pdf-viewer 1.0.2 → 1.1.1
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 +3 -1
- package/pdfjs/dist/display_utils.js +714 -714
- package/pdfjs/dist/fetch_stream.js +293 -293
- package/pdfjs/dist/l10n_utils.js +122 -122
- package/pdfjs/dist/message_handler.js +524 -524
- package/pdfjs/dist/network.js +552 -552
- package/pdfjs/dist/network_utils.js +309 -309
- package/pdfjs/dist/node_stream.js +481 -481
- package/pdfjs/dist/pdf_link_service.js +534 -534
- package/pdfjs/dist/pdf_rendering_queue.js +154 -154
- package/pdfjs/dist/pdf_thumbnail_viewer.js +738 -738
- package/pdfjs/dist/pdf_viewer.js +3207 -3207
- package/pdfjs/dist/ui_utils.js +881 -881
- package/pdfjs/dist/util.js +991 -991
- package/pdfjs/dist/worker.js +60846 -60846
- package/src/vcf-pdf-viewer.js +48 -8
- package/theme/lumo/vcf-pdf-viewer-styles.js +6 -6
- package/theme/material/vcf-pdf-viewer-styles.js +4 -4
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import './pdf.js';
|
|
2
|
-
import { R as RenderingCancelledException } from './display_utils.js';
|
|
3
|
-
import './util.js';
|
|
4
|
-
import './message_handler.js';
|
|
5
|
-
|
|
1
|
+
import './pdf.js';
|
|
2
|
+
import { R as RenderingCancelledException } from './display_utils.js';
|
|
3
|
+
import './util.js';
|
|
4
|
+
import './message_handler.js';
|
|
5
|
+
|
|
6
6
|
/* Copyright 2012 Mozilla Foundation
|
|
7
7
|
*
|
|
8
8
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
@@ -16,93 +16,93 @@ import './message_handler.js';
|
|
|
16
16
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
17
17
|
* See the License for the specific language governing permissions and
|
|
18
18
|
* limitations under the License.
|
|
19
|
-
*/
|
|
20
|
-
const CLEANUP_TIMEOUT = 30000;
|
|
21
|
-
const RenderingStates = {
|
|
22
|
-
INITIAL: 0,
|
|
23
|
-
RUNNING: 1,
|
|
24
|
-
PAUSED: 2,
|
|
25
|
-
FINISHED: 3
|
|
26
|
-
};
|
|
19
|
+
*/
|
|
20
|
+
const CLEANUP_TIMEOUT = 30000;
|
|
21
|
+
const RenderingStates = {
|
|
22
|
+
INITIAL: 0,
|
|
23
|
+
RUNNING: 1,
|
|
24
|
+
PAUSED: 2,
|
|
25
|
+
FINISHED: 3
|
|
26
|
+
};
|
|
27
27
|
/**
|
|
28
28
|
* Controls rendering of the views for pages and thumbnails.
|
|
29
|
-
*/
|
|
30
|
-
|
|
31
|
-
class PDFRenderingQueue {
|
|
32
|
-
constructor() {
|
|
33
|
-
this.pdfViewer = null;
|
|
34
|
-
this.pdfThumbnailViewer = null;
|
|
35
|
-
this.onIdle = null;
|
|
36
|
-
this.highestPriorityPage = null;
|
|
37
|
-
this.idleTimeout = null;
|
|
38
|
-
this.printing = false;
|
|
39
|
-
this.isThumbnailViewEnabled = false;
|
|
40
|
-
}
|
|
29
|
+
*/
|
|
30
|
+
|
|
31
|
+
class PDFRenderingQueue {
|
|
32
|
+
constructor() {
|
|
33
|
+
this.pdfViewer = null;
|
|
34
|
+
this.pdfThumbnailViewer = null;
|
|
35
|
+
this.onIdle = null;
|
|
36
|
+
this.highestPriorityPage = null;
|
|
37
|
+
this.idleTimeout = null;
|
|
38
|
+
this.printing = false;
|
|
39
|
+
this.isThumbnailViewEnabled = false;
|
|
40
|
+
}
|
|
41
41
|
/**
|
|
42
42
|
* @param {PDFViewer} pdfViewer
|
|
43
|
-
*/
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
setViewer(pdfViewer) {
|
|
47
|
-
this.pdfViewer = pdfViewer;
|
|
48
|
-
}
|
|
43
|
+
*/
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
setViewer(pdfViewer) {
|
|
47
|
+
this.pdfViewer = pdfViewer;
|
|
48
|
+
}
|
|
49
49
|
/**
|
|
50
50
|
* @param {PDFThumbnailViewer} pdfThumbnailViewer
|
|
51
|
-
*/
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
setThumbnailViewer(pdfThumbnailViewer) {
|
|
55
|
-
this.pdfThumbnailViewer = pdfThumbnailViewer;
|
|
56
|
-
}
|
|
51
|
+
*/
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
setThumbnailViewer(pdfThumbnailViewer) {
|
|
55
|
+
this.pdfThumbnailViewer = pdfThumbnailViewer;
|
|
56
|
+
}
|
|
57
57
|
/**
|
|
58
58
|
* @param {IRenderableView} view
|
|
59
59
|
* @returns {boolean}
|
|
60
|
-
*/
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
isHighestPriority(view) {
|
|
64
|
-
return this.highestPriorityPage === view.renderingId;
|
|
65
|
-
}
|
|
60
|
+
*/
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
isHighestPriority(view) {
|
|
64
|
+
return this.highestPriorityPage === view.renderingId;
|
|
65
|
+
}
|
|
66
66
|
/**
|
|
67
67
|
* @param {Object} currentlyVisiblePages
|
|
68
|
-
*/
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
renderHighestPriority(currentlyVisiblePages) {
|
|
72
|
-
if (this.idleTimeout) {
|
|
73
|
-
clearTimeout(this.idleTimeout);
|
|
74
|
-
this.idleTimeout = null;
|
|
75
|
-
} // Pages have a higher priority than thumbnails, so check them first.
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
if (this.pdfViewer.forceRendering(currentlyVisiblePages)) {
|
|
79
|
-
return;
|
|
80
|
-
} // No pages needed rendering, so check thumbnails.
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
if (this.pdfThumbnailViewer && this.isThumbnailViewEnabled) {
|
|
84
|
-
if (this.pdfThumbnailViewer.forceRendering()) {
|
|
85
|
-
return;
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
if (this.printing) {
|
|
90
|
-
// If printing is currently ongoing do not reschedule cleanup.
|
|
91
|
-
return;
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
if (this.onIdle) {
|
|
95
|
-
this.idleTimeout = setTimeout(this.onIdle.bind(this), CLEANUP_TIMEOUT);
|
|
96
|
-
}
|
|
97
|
-
}
|
|
68
|
+
*/
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
renderHighestPriority(currentlyVisiblePages) {
|
|
72
|
+
if (this.idleTimeout) {
|
|
73
|
+
clearTimeout(this.idleTimeout);
|
|
74
|
+
this.idleTimeout = null;
|
|
75
|
+
} // Pages have a higher priority than thumbnails, so check them first.
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
if (this.pdfViewer.forceRendering(currentlyVisiblePages)) {
|
|
79
|
+
return;
|
|
80
|
+
} // No pages needed rendering, so check thumbnails.
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
if (this.pdfThumbnailViewer && this.isThumbnailViewEnabled) {
|
|
84
|
+
if (this.pdfThumbnailViewer.forceRendering()) {
|
|
85
|
+
return;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
if (this.printing) {
|
|
90
|
+
// If printing is currently ongoing do not reschedule cleanup.
|
|
91
|
+
return;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
if (this.onIdle) {
|
|
95
|
+
this.idleTimeout = setTimeout(this.onIdle.bind(this), CLEANUP_TIMEOUT);
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
98
|
/**
|
|
99
99
|
* @param {Object} visible
|
|
100
100
|
* @param {Array} views
|
|
101
101
|
* @param {boolean} scrolledDown
|
|
102
|
-
*/
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
getHighestPriority(visible, views, scrolledDown) {
|
|
102
|
+
*/
|
|
103
|
+
|
|
104
|
+
|
|
105
|
+
getHighestPriority(visible, views, scrolledDown) {
|
|
106
106
|
/**
|
|
107
107
|
* The state has changed. Figure out which page has the highest priority to
|
|
108
108
|
* render next (if any).
|
|
@@ -111,89 +111,89 @@ class PDFRenderingQueue {
|
|
|
111
111
|
* 1. visible pages
|
|
112
112
|
* 2. if last scrolled down, the page after the visible pages, or
|
|
113
113
|
* if last scrolled up, the page before the visible pages
|
|
114
|
-
*/
|
|
115
|
-
const visibleViews = visible.views;
|
|
116
|
-
const numVisible = visibleViews.length;
|
|
117
|
-
|
|
118
|
-
if (numVisible === 0) {
|
|
119
|
-
return null;
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
for (let i = 0; i < numVisible; ++i) {
|
|
123
|
-
const view = visibleViews[i].view;
|
|
124
|
-
|
|
125
|
-
if (!this.isViewFinished(view)) {
|
|
126
|
-
return view;
|
|
127
|
-
}
|
|
128
|
-
} // All the visible views have rendered; try to render next/previous pages.
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
if (scrolledDown) {
|
|
132
|
-
const nextPageIndex = visible.last.id; // IDs start at 1, so no need to add 1.
|
|
133
|
-
|
|
134
|
-
if (views[nextPageIndex] && !this.isViewFinished(views[nextPageIndex])) {
|
|
135
|
-
return views[nextPageIndex];
|
|
136
|
-
}
|
|
137
|
-
} else {
|
|
138
|
-
const previousPageIndex = visible.first.id - 2;
|
|
139
|
-
|
|
140
|
-
if (views[previousPageIndex] && !this.isViewFinished(views[previousPageIndex])) {
|
|
141
|
-
return views[previousPageIndex];
|
|
142
|
-
}
|
|
143
|
-
} // Everything that needs to be rendered has been.
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
return null;
|
|
147
|
-
}
|
|
114
|
+
*/
|
|
115
|
+
const visibleViews = visible.views;
|
|
116
|
+
const numVisible = visibleViews.length;
|
|
117
|
+
|
|
118
|
+
if (numVisible === 0) {
|
|
119
|
+
return null;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
for (let i = 0; i < numVisible; ++i) {
|
|
123
|
+
const view = visibleViews[i].view;
|
|
124
|
+
|
|
125
|
+
if (!this.isViewFinished(view)) {
|
|
126
|
+
return view;
|
|
127
|
+
}
|
|
128
|
+
} // All the visible views have rendered; try to render next/previous pages.
|
|
129
|
+
|
|
130
|
+
|
|
131
|
+
if (scrolledDown) {
|
|
132
|
+
const nextPageIndex = visible.last.id; // IDs start at 1, so no need to add 1.
|
|
133
|
+
|
|
134
|
+
if (views[nextPageIndex] && !this.isViewFinished(views[nextPageIndex])) {
|
|
135
|
+
return views[nextPageIndex];
|
|
136
|
+
}
|
|
137
|
+
} else {
|
|
138
|
+
const previousPageIndex = visible.first.id - 2;
|
|
139
|
+
|
|
140
|
+
if (views[previousPageIndex] && !this.isViewFinished(views[previousPageIndex])) {
|
|
141
|
+
return views[previousPageIndex];
|
|
142
|
+
}
|
|
143
|
+
} // Everything that needs to be rendered has been.
|
|
144
|
+
|
|
145
|
+
|
|
146
|
+
return null;
|
|
147
|
+
}
|
|
148
148
|
/**
|
|
149
149
|
* @param {IRenderableView} view
|
|
150
150
|
* @returns {boolean}
|
|
151
|
-
*/
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
isViewFinished(view) {
|
|
155
|
-
return view.renderingState === RenderingStates.FINISHED;
|
|
156
|
-
}
|
|
151
|
+
*/
|
|
152
|
+
|
|
153
|
+
|
|
154
|
+
isViewFinished(view) {
|
|
155
|
+
return view.renderingState === RenderingStates.FINISHED;
|
|
156
|
+
}
|
|
157
157
|
/**
|
|
158
158
|
* Render a page or thumbnail view. This calls the appropriate function
|
|
159
159
|
* based on the views state. If the view is already rendered it will return
|
|
160
160
|
* `false`.
|
|
161
161
|
*
|
|
162
162
|
* @param {IRenderableView} view
|
|
163
|
-
*/
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
renderView(view) {
|
|
167
|
-
switch (view.renderingState) {
|
|
168
|
-
case RenderingStates.FINISHED:
|
|
169
|
-
return false;
|
|
170
|
-
|
|
171
|
-
case RenderingStates.PAUSED:
|
|
172
|
-
this.highestPriorityPage = view.renderingId;
|
|
173
|
-
view.resume();
|
|
174
|
-
break;
|
|
175
|
-
|
|
176
|
-
case RenderingStates.RUNNING:
|
|
177
|
-
this.highestPriorityPage = view.renderingId;
|
|
178
|
-
break;
|
|
179
|
-
|
|
180
|
-
case RenderingStates.INITIAL:
|
|
181
|
-
this.highestPriorityPage = view.renderingId;
|
|
182
|
-
view.draw().finally(() => {
|
|
183
|
-
this.renderHighestPriority();
|
|
184
|
-
}).catch(reason => {
|
|
185
|
-
if (reason instanceof RenderingCancelledException) {
|
|
186
|
-
return;
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
console.error(`renderView: "${reason}"`);
|
|
190
|
-
});
|
|
191
|
-
break;
|
|
192
|
-
}
|
|
193
|
-
|
|
194
|
-
return true;
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
}
|
|
198
|
-
|
|
199
|
-
export { PDFRenderingQueue, RenderingStates };
|
|
163
|
+
*/
|
|
164
|
+
|
|
165
|
+
|
|
166
|
+
renderView(view) {
|
|
167
|
+
switch (view.renderingState) {
|
|
168
|
+
case RenderingStates.FINISHED:
|
|
169
|
+
return false;
|
|
170
|
+
|
|
171
|
+
case RenderingStates.PAUSED:
|
|
172
|
+
this.highestPriorityPage = view.renderingId;
|
|
173
|
+
view.resume();
|
|
174
|
+
break;
|
|
175
|
+
|
|
176
|
+
case RenderingStates.RUNNING:
|
|
177
|
+
this.highestPriorityPage = view.renderingId;
|
|
178
|
+
break;
|
|
179
|
+
|
|
180
|
+
case RenderingStates.INITIAL:
|
|
181
|
+
this.highestPriorityPage = view.renderingId;
|
|
182
|
+
view.draw().finally(() => {
|
|
183
|
+
this.renderHighestPriority();
|
|
184
|
+
}).catch(reason => {
|
|
185
|
+
if (reason instanceof RenderingCancelledException) {
|
|
186
|
+
return;
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
console.error(`renderView: "${reason}"`);
|
|
190
|
+
});
|
|
191
|
+
break;
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
return true;
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
export { PDFRenderingQueue, RenderingStates };
|