@vertexvis/doc-viewer 1.0.2-canary.2 → 1.0.2-canary.21
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/cjs/vertex-document-viewer.cjs.entry.js +125 -277
- package/dist/collection/__mocks__/pdfjs-mock.js +2 -1
- package/dist/collection/components/document-viewer/document-viewer.css +11 -0
- package/dist/collection/components/document-viewer/document-viewer.js +18 -6
- package/dist/collection/lib/document/layers/controller.js +12 -0
- package/dist/collection/lib/dom.js +3 -0
- package/dist/collection/lib/interactions/pan-interaction-handler.js +1 -1
- package/dist/collection/lib/pdf/pdfjs-renderer.js +10 -1
- package/dist/components/vertex-document-viewer.js +2 -2
- package/dist/doc-viewer/doc-viewer.esm.js +1 -1
- package/dist/doc-viewer/p-49c08e34.entry.js +25 -0
- package/dist/esm/vertex-document-viewer.entry.js +125 -277
- package/dist/types/__mocks__/pdfjs-mock.d.ts +3 -2
- 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 +2 -0
- package/dist/types/index.d.ts +1 -0
- package/dist/types/lib/config.d.ts +1 -0
- package/dist/types/lib/document/api.d.ts +1 -0
- package/dist/types/lib/document/layers/controller.d.ts +4 -1
- package/dist/types/lib/document/layers/index.d.ts +1 -0
- package/dist/types/lib/document/layers/types.d.ts +1 -0
- package/dist/types/lib/document/provider.d.ts +1 -0
- package/dist/types/lib/document/renderer.d.ts +1 -0
- package/dist/types/lib/dom.d.ts +2 -0
- package/dist/types/lib/index.d.ts +1 -0
- package/dist/types/lib/interactions/pan-interaction-handler.d.ts +1 -0
- package/dist/types/lib/pdf/pdfjs-api.d.ts +1 -0
- package/dist/types/lib/pdf/pdfjs-provider.d.ts +1 -0
- package/dist/types/lib/pdf/pdfjs-renderer.d.ts +1 -0
- package/dist/types/lib/types/loadableResource.d.ts +1 -0
- package/dist/types/polyfill/index.d.ts +1 -0
- package/dist/types/polyfill/resize-observer.d.ts +1 -0
- package/dist/types/testing/mock-document-api.d.ts +1 -0
- package/package.json +6 -6
- package/dist/doc-viewer/p-f5810a8d.entry.js +0 -25
|
@@ -7,91 +7,6 @@ function getDefaultExportFromCjs (x) {
|
|
|
7
7
|
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
|
|
8
8
|
}
|
|
9
9
|
|
|
10
|
-
/******************************************************************************
|
|
11
|
-
Copyright (c) Microsoft Corporation.
|
|
12
|
-
|
|
13
|
-
Permission to use, copy, modify, and/or distribute this software for any
|
|
14
|
-
purpose with or without fee is hereby granted.
|
|
15
|
-
|
|
16
|
-
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
17
|
-
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
18
|
-
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
19
|
-
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
20
|
-
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
21
|
-
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
22
|
-
PERFORMANCE OF THIS SOFTWARE.
|
|
23
|
-
***************************************************************************** */
|
|
24
|
-
/* global Reflect, Promise, SuppressedError, Symbol, Iterator */
|
|
25
|
-
|
|
26
|
-
var extendStatics = function(d, b) {
|
|
27
|
-
extendStatics = Object.setPrototypeOf ||
|
|
28
|
-
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
29
|
-
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
30
|
-
return extendStatics(d, b);
|
|
31
|
-
};
|
|
32
|
-
|
|
33
|
-
function __extends(d, b) {
|
|
34
|
-
if (typeof b !== "function" && b !== null)
|
|
35
|
-
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
36
|
-
extendStatics(d, b);
|
|
37
|
-
function __() { this.constructor = d; }
|
|
38
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
var __assign = function() {
|
|
42
|
-
__assign = Object.assign || function __assign(t) {
|
|
43
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
44
|
-
s = arguments[i];
|
|
45
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
|
|
46
|
-
}
|
|
47
|
-
return t;
|
|
48
|
-
};
|
|
49
|
-
return __assign.apply(this, arguments);
|
|
50
|
-
};
|
|
51
|
-
|
|
52
|
-
function __awaiter(thisArg, _arguments, P, generator) {
|
|
53
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
54
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
55
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
56
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
57
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
58
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
59
|
-
});
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
function __generator(thisArg, body) {
|
|
63
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
|
64
|
-
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
65
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
66
|
-
function step(op) {
|
|
67
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
68
|
-
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
69
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
70
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
71
|
-
switch (op[0]) {
|
|
72
|
-
case 0: case 1: t = op; break;
|
|
73
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
74
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
75
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
76
|
-
default:
|
|
77
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
78
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
79
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
80
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
81
|
-
if (t[2]) _.ops.pop();
|
|
82
|
-
_.trys.pop(); continue;
|
|
83
|
-
}
|
|
84
|
-
op = body.call(thisArg, _);
|
|
85
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
86
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
|
|
91
|
-
var e = new Error(message);
|
|
92
|
-
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
93
|
-
};
|
|
94
|
-
|
|
95
10
|
/**
|
|
96
11
|
* Clamps the given value between `min` and `max`.
|
|
97
12
|
*
|
|
@@ -121,24 +36,22 @@ function lerp$2(a, b, t) {
|
|
|
121
36
|
/**
|
|
122
37
|
* Returns a new `Point` with the given horizontal and vertical position.
|
|
123
38
|
*/
|
|
124
|
-
function create$d(x, y) {
|
|
125
|
-
|
|
126
|
-
if (y === void 0) { y = 0; }
|
|
127
|
-
return { x: x, y: y };
|
|
39
|
+
function create$d(x = 0, y = 0) {
|
|
40
|
+
return { x, y };
|
|
128
41
|
}
|
|
129
42
|
/**
|
|
130
43
|
* Converts a polar coordinate (length and angle) into a Cartesian coordinate.
|
|
131
44
|
*/
|
|
132
45
|
function polar(length, radians) {
|
|
133
|
-
|
|
134
|
-
|
|
46
|
+
const x = Math.cos(radians) * length;
|
|
47
|
+
const y = Math.sin(radians) * length;
|
|
135
48
|
return create$d(x, y);
|
|
136
49
|
}
|
|
137
50
|
/**
|
|
138
51
|
* Returns the distance between two points.
|
|
139
52
|
*/
|
|
140
53
|
function distance$2(a, b) {
|
|
141
|
-
|
|
54
|
+
const delta = subtract$1(a, b);
|
|
142
55
|
return Math.sqrt(delta.x * delta.x + delta.y * delta.y);
|
|
143
56
|
}
|
|
144
57
|
/**
|
|
@@ -210,7 +123,7 @@ function magnitude$2(pt) {
|
|
|
210
123
|
* Transforms a vector into the corresponding normal (unit) vector.
|
|
211
124
|
*/
|
|
212
125
|
function normalizeVector(pt) {
|
|
213
|
-
|
|
126
|
+
const magnitudeOfPoint = magnitude$2(pt);
|
|
214
127
|
if (magnitudeOfPoint === 0) {
|
|
215
128
|
return create$d(0, 0);
|
|
216
129
|
}
|
|
@@ -228,19 +141,19 @@ function normalDirectionVector(ptA, ptB) {
|
|
|
228
141
|
* Returns a vector orthogonal to the vector between the two given points.
|
|
229
142
|
*/
|
|
230
143
|
function orthogonalVector(ptA, ptB) {
|
|
231
|
-
|
|
144
|
+
const unitVectorBetweenPoints = normalDirectionVector(ptA, ptB);
|
|
232
145
|
// Handle vectors that are parallel to the x or y axis
|
|
233
146
|
if (unitVectorBetweenPoints.x === 0 || unitVectorBetweenPoints.y === 0) {
|
|
234
147
|
return create$d(-1 * unitVectorBetweenPoints.y, unitVectorBetweenPoints.x);
|
|
235
148
|
}
|
|
236
149
|
if (Math.abs(unitVectorBetweenPoints.x) > Math.abs(unitVectorBetweenPoints.y)) {
|
|
237
|
-
|
|
238
|
-
|
|
150
|
+
const vectorXValue = 1 - Math.pow(unitVectorBetweenPoints.x, 2);
|
|
151
|
+
const vectorYValue = -1 * unitVectorBetweenPoints.x * unitVectorBetweenPoints.y;
|
|
239
152
|
return normalizeVector(create$d(vectorXValue, vectorYValue));
|
|
240
153
|
}
|
|
241
154
|
else {
|
|
242
|
-
|
|
243
|
-
|
|
155
|
+
const vectorXValue = -1 * unitVectorBetweenPoints.x * unitVectorBetweenPoints.y;
|
|
156
|
+
const vectorYValue = 1 - Math.pow(unitVectorBetweenPoints.y, 2);
|
|
244
157
|
return normalizeVector(create$d(vectorXValue, vectorYValue));
|
|
245
158
|
}
|
|
246
159
|
}
|
|
@@ -251,13 +164,13 @@ function orthogonalVector(ptA, ptB) {
|
|
|
251
164
|
* @returns A parsed Point.
|
|
252
165
|
*/
|
|
253
166
|
function fromJson$5(json) {
|
|
254
|
-
|
|
167
|
+
const obj = JSON.parse(json);
|
|
255
168
|
if (Array.isArray(obj)) {
|
|
256
|
-
|
|
169
|
+
const [x, y] = obj;
|
|
257
170
|
return create$d(x, y);
|
|
258
171
|
}
|
|
259
172
|
else {
|
|
260
|
-
|
|
173
|
+
const { x, y } = obj;
|
|
261
174
|
return create$d(x, y);
|
|
262
175
|
}
|
|
263
176
|
}
|
|
@@ -285,7 +198,7 @@ var point = /*#__PURE__*/Object.freeze({
|
|
|
285
198
|
* Returns a new `Rectangle` with the given position and size.
|
|
286
199
|
*/
|
|
287
200
|
function create$7(x, y, width, height) {
|
|
288
|
-
return { x
|
|
201
|
+
return { x, y, width, height };
|
|
289
202
|
}
|
|
290
203
|
/**
|
|
291
204
|
* Returns a new `Rectangle` with the given position and size.
|
|
@@ -302,9 +215,9 @@ function fromPointAndDimensions(point, dimensions) {
|
|
|
302
215
|
* @see {@link cropFit}
|
|
303
216
|
*/
|
|
304
217
|
function containFit$1(to, rect) {
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
218
|
+
const scale = Math.min(to.width / rect.width, to.height / rect.height);
|
|
219
|
+
const dimensions$1 = proportionalScale(scale, rect);
|
|
220
|
+
const position = subtract$1(center$2(to), center$1(dimensions$1));
|
|
308
221
|
return fromPointAndDimensions(position, dimensions$1);
|
|
309
222
|
}
|
|
310
223
|
/**
|
|
@@ -316,9 +229,9 @@ function containFit$1(to, rect) {
|
|
|
316
229
|
* @see {@link containFit}
|
|
317
230
|
*/
|
|
318
231
|
function cropFit$1(to, rect) {
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
232
|
+
const scale = Math.max(to.width / rect.width, to.height / rect.height);
|
|
233
|
+
const dimensions$1 = proportionalScale(scale, rect);
|
|
234
|
+
const position = subtract$1(center$2(to), center$1(dimensions$1));
|
|
322
235
|
return fromPointAndDimensions(position, dimensions$1);
|
|
323
236
|
}
|
|
324
237
|
/**
|
|
@@ -330,9 +243,9 @@ function cropFit$1(to, rect) {
|
|
|
330
243
|
* @param rect - the rectangle to scale to fit the specified area
|
|
331
244
|
*/
|
|
332
245
|
function scaleFit$1(to, rect) {
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
246
|
+
const scale = Math.min(Math.sqrt(to / area$1(rect)), 1);
|
|
247
|
+
const dimensions$1 = floor$1(proportionalScale(scale, rect));
|
|
248
|
+
const position = subtract$1(center$2(rect), center$1(dimensions$1));
|
|
336
249
|
return fromPointAndDimensions(position, dimensions$1);
|
|
337
250
|
}
|
|
338
251
|
/**
|
|
@@ -352,27 +265,27 @@ function center$2(rect) {
|
|
|
352
265
|
* Returns a `Dimensions` with the given width and height.
|
|
353
266
|
*
|
|
354
267
|
*/
|
|
355
|
-
|
|
356
|
-
return { width
|
|
268
|
+
const create$6 = (width, height) => {
|
|
269
|
+
return { width, height };
|
|
357
270
|
};
|
|
358
271
|
/**
|
|
359
272
|
* Returns a `Dimensions` with the same width and height.
|
|
360
273
|
*/
|
|
361
|
-
|
|
274
|
+
const square = (size) => {
|
|
362
275
|
return create$6(size, size);
|
|
363
276
|
};
|
|
364
277
|
/**
|
|
365
278
|
* Returns `true` if two dimensions have the same width and height. Otherwise
|
|
366
279
|
* `false`.
|
|
367
280
|
*/
|
|
368
|
-
|
|
281
|
+
const isEqual = (a, b) => {
|
|
369
282
|
return a.width === b.width && a.height === b.height;
|
|
370
283
|
};
|
|
371
284
|
/**
|
|
372
285
|
* Returns a scaled dimensions, where the width is scaled by `scaleX` and height
|
|
373
286
|
* is scaled by `scaleY`.
|
|
374
287
|
*/
|
|
375
|
-
|
|
288
|
+
const scale = (scaleX, scaleY, dimensions) => {
|
|
376
289
|
return {
|
|
377
290
|
width: dimensions.width * scaleX,
|
|
378
291
|
height: dimensions.height * scaleY,
|
|
@@ -381,14 +294,14 @@ var scale = function (scaleX, scaleY, dimensions) {
|
|
|
381
294
|
/**
|
|
382
295
|
* Returns a dimension where each length is scaled by `scaleFactor`.
|
|
383
296
|
*/
|
|
384
|
-
|
|
297
|
+
const proportionalScale = (scaleFactor, dimensions) => {
|
|
385
298
|
return scale(scaleFactor, scaleFactor, dimensions);
|
|
386
299
|
};
|
|
387
300
|
/**
|
|
388
301
|
* Returns a `Dimensions` where the lengths of `dimensions` are trimmed to fit
|
|
389
302
|
* into `to`.
|
|
390
303
|
*/
|
|
391
|
-
|
|
304
|
+
const trim = (to, dimensions) => {
|
|
392
305
|
return {
|
|
393
306
|
width: Math.min(to.width, dimensions.width),
|
|
394
307
|
height: Math.min(to.height, dimensions.height),
|
|
@@ -401,9 +314,9 @@ var trim = function (to, dimensions) {
|
|
|
401
314
|
*
|
|
402
315
|
* @see #cropFit()
|
|
403
316
|
*/
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
return { width
|
|
317
|
+
const containFit = (to, dimensions) => {
|
|
318
|
+
const { width, height } = containFit$1(toRectangle(to), toRectangle(dimensions));
|
|
319
|
+
return { width, height };
|
|
407
320
|
};
|
|
408
321
|
/**
|
|
409
322
|
* Returns a `Dimensions` where the shortest length of `dimensions` will be
|
|
@@ -412,9 +325,9 @@ var containFit = function (to, dimensions) {
|
|
|
412
325
|
*
|
|
413
326
|
* @see #containFit()
|
|
414
327
|
*/
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
return { width
|
|
328
|
+
const cropFit = (to, dimensions) => {
|
|
329
|
+
const { width, height } = cropFit$1(toRectangle(to), toRectangle(dimensions));
|
|
330
|
+
return { width, height };
|
|
418
331
|
};
|
|
419
332
|
/**
|
|
420
333
|
* Returns a `Dimensions` where each side of `dimensions` will be reduced proportionally
|
|
@@ -424,14 +337,14 @@ var cropFit = function (to, dimensions) {
|
|
|
424
337
|
* @param to - the maximum area this dimensions can have
|
|
425
338
|
* @param dimensions - the dimensions to scale to fit the specified area
|
|
426
339
|
*/
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
return { width
|
|
340
|
+
const scaleFit = (to, dimensions) => {
|
|
341
|
+
const { width, height } = scaleFit$1(to, toRectangle(dimensions));
|
|
342
|
+
return { width, height };
|
|
430
343
|
};
|
|
431
344
|
/**
|
|
432
345
|
* Returns a `Dimensions` with each length rounded.
|
|
433
346
|
*/
|
|
434
|
-
|
|
347
|
+
const round = (dimensions) => {
|
|
435
348
|
return {
|
|
436
349
|
width: Math.round(dimensions.width),
|
|
437
350
|
height: Math.round(dimensions.height),
|
|
@@ -440,7 +353,7 @@ var round = function (dimensions) {
|
|
|
440
353
|
/**
|
|
441
354
|
* Returns a `Dimensions` with each length rounded down.
|
|
442
355
|
*/
|
|
443
|
-
|
|
356
|
+
const floor$1 = (dimensions) => {
|
|
444
357
|
return {
|
|
445
358
|
width: Math.floor(dimensions.width),
|
|
446
359
|
height: Math.floor(dimensions.height),
|
|
@@ -449,22 +362,20 @@ var floor$1 = function (dimensions) {
|
|
|
449
362
|
/**
|
|
450
363
|
* Returns the center point of the given `dimensions`.
|
|
451
364
|
*/
|
|
452
|
-
|
|
365
|
+
const center$1 = (dimensions) => {
|
|
453
366
|
return { x: dimensions.width / 2, y: dimensions.height / 2 };
|
|
454
367
|
};
|
|
455
368
|
/**
|
|
456
369
|
* Returns the aspect ratio of the given `dimensions`, as defined by width over
|
|
457
370
|
* height.
|
|
458
371
|
*/
|
|
459
|
-
|
|
460
|
-
var width = _a.width, height = _a.height;
|
|
372
|
+
const aspectRatio = ({ width, height }) => {
|
|
461
373
|
return width / height;
|
|
462
374
|
};
|
|
463
375
|
/**
|
|
464
376
|
* Returns the area of the given `dimensions`.
|
|
465
377
|
*/
|
|
466
|
-
|
|
467
|
-
var width = _a.width, height = _a.height;
|
|
378
|
+
const area = ({ width, height }) => {
|
|
468
379
|
return width * height;
|
|
469
380
|
};
|
|
470
381
|
/**
|
|
@@ -473,7 +384,7 @@ var area = function (_a) {
|
|
|
473
384
|
* @param ratio - Aspect ratio to fit the provided Dimensions to
|
|
474
385
|
* @param dimensions - Dimensions to fit to the specified ratio
|
|
475
386
|
*/
|
|
476
|
-
|
|
387
|
+
const fitToRatio = (ratio, dimensions) => {
|
|
477
388
|
if (dimensions.width >= dimensions.height * ratio) {
|
|
478
389
|
return create$6(dimensions.height * ratio, dimensions.height);
|
|
479
390
|
}
|
|
@@ -482,8 +393,7 @@ var fitToRatio = function (ratio, dimensions) {
|
|
|
482
393
|
/**
|
|
483
394
|
* Converts a dimension to a rectangle, with an optional position.
|
|
484
395
|
*/
|
|
485
|
-
function toRectangle(dimensions, position) {
|
|
486
|
-
if (position === void 0) { position = create$d(); }
|
|
396
|
+
function toRectangle(dimensions, position = create$d()) {
|
|
487
397
|
return fromPointAndDimensions(position, dimensions);
|
|
488
398
|
}
|
|
489
399
|
|
|
@@ -604,10 +514,22 @@ function apiSupportsLayers(api) {
|
|
|
604
514
|
class DocumentLayersController {
|
|
605
515
|
constructor(api) {
|
|
606
516
|
this.apiSupportsLayers = false;
|
|
517
|
+
if (api != null) {
|
|
518
|
+
this.setApi(api);
|
|
519
|
+
}
|
|
520
|
+
}
|
|
521
|
+
setApi(api) {
|
|
607
522
|
if (apiSupportsLayers(api)) {
|
|
608
523
|
this.apiSupportsLayers = true;
|
|
609
524
|
this.api = api;
|
|
610
525
|
}
|
|
526
|
+
else {
|
|
527
|
+
this.clear();
|
|
528
|
+
}
|
|
529
|
+
}
|
|
530
|
+
clear() {
|
|
531
|
+
this.apiSupportsLayers = false;
|
|
532
|
+
this.api = undefined;
|
|
611
533
|
}
|
|
612
534
|
/**
|
|
613
535
|
* Returns a boolean indicating whether the document supports layers.
|
|
@@ -642,6 +564,9 @@ class DocumentLayersController {
|
|
|
642
564
|
function getElementBoundingClientRect(element) {
|
|
643
565
|
return element.getBoundingClientRect();
|
|
644
566
|
}
|
|
567
|
+
function createElement(tagName) {
|
|
568
|
+
return document.createElement(tagName);
|
|
569
|
+
}
|
|
645
570
|
function getAllVertexElementChildren(element) {
|
|
646
571
|
return getAllChildren(element)
|
|
647
572
|
.filter(node => node.nodeName.startsWith('VERTEX-'))
|
|
@@ -681,7 +606,7 @@ class PanInteractionHandler {
|
|
|
681
606
|
}
|
|
682
607
|
}
|
|
683
608
|
handlePointerDown(event) {
|
|
684
|
-
if (event.button !==
|
|
609
|
+
if (event.button !== 2) {
|
|
685
610
|
return;
|
|
686
611
|
}
|
|
687
612
|
event.preventDefault();
|
|
@@ -34181,153 +34106,56 @@ globalThis.pdfjsLib = {
|
|
|
34181
34106
|
XfaLayer: XfaLayer
|
|
34182
34107
|
};
|
|
34183
34108
|
|
|
34184
|
-
|
|
34185
|
-
|
|
34186
|
-
* module is useful for parsing to or from JSON/protobufs to domain types.
|
|
34187
|
-
*
|
|
34188
|
-
* Mappers support greedy validation, so all validation errors are aggregated
|
|
34189
|
-
* and reported vs failing on the first invalid input.
|
|
34190
|
-
*
|
|
34191
|
-
* @example
|
|
34192
|
-
*
|
|
34193
|
-
* ```ts
|
|
34194
|
-
* import { Mapper as M } from '@vertexvis/utils';
|
|
34195
|
-
*
|
|
34196
|
-
* interface Address {
|
|
34197
|
-
* address: string;
|
|
34198
|
-
* city: string;
|
|
34199
|
-
* state: string;
|
|
34200
|
-
* zip: string;
|
|
34201
|
-
* }
|
|
34202
|
-
*
|
|
34203
|
-
* interface Person {
|
|
34204
|
-
* name: string;
|
|
34205
|
-
* addresses: Address[];
|
|
34206
|
-
* }
|
|
34207
|
-
*
|
|
34208
|
-
* type AddressJson = Partial<Address>;
|
|
34209
|
-
* type PersonJson = {
|
|
34210
|
-
* name?: string;
|
|
34211
|
-
* addresses?: AddressJson[];
|
|
34212
|
-
* }
|
|
34213
|
-
*
|
|
34214
|
-
* const mapAddress: M.Func<AddressJson, Address> = M.defineMapper(
|
|
34215
|
-
* M.read(
|
|
34216
|
-
* M.requireProp('address'),
|
|
34217
|
-
* M.requireProp('city'),
|
|
34218
|
-
* M.requireProp('state'),
|
|
34219
|
-
* M.requireProp('zip')
|
|
34220
|
-
* ),
|
|
34221
|
-
* ([address, city, state, zip]) => ({
|
|
34222
|
-
* address, city, state, zip
|
|
34223
|
-
* })
|
|
34224
|
-
* );
|
|
34225
|
-
*
|
|
34226
|
-
* const mapPerson: M.Func<PersonJson, Person> = M.defineMapper(
|
|
34227
|
-
* M.read(
|
|
34228
|
-
* M.requireProp('name'),
|
|
34229
|
-
* M.mapProp(
|
|
34230
|
-
* 'addresses',
|
|
34231
|
-
* M.compose(M.required('addresses'), M.mapArray(mapAddress))
|
|
34232
|
-
* )
|
|
34233
|
-
* ),
|
|
34234
|
-
* ([name, addresses]) => ({ name, addresses })
|
|
34235
|
-
* );
|
|
34236
|
-
*
|
|
34237
|
-
* const person = mapPerson({
|
|
34238
|
-
* name: 'John',
|
|
34239
|
-
* addresses: [{ address: '123', city: 'Ames', state: 'IA', zip: '50010' }]
|
|
34240
|
-
* });
|
|
34241
|
-
*
|
|
34242
|
-
* const invalidPerson = mapPerson({
|
|
34243
|
-
* addresses: [{ city: 'Ames', state: 'IA', zip: '50010' }]
|
|
34244
|
-
* });
|
|
34245
|
-
* ```
|
|
34246
|
-
* // {
|
|
34247
|
-
* // errors: ["Name is required.", "Address is required."]
|
|
34248
|
-
* // }
|
|
34249
|
-
*
|
|
34250
|
-
* @module
|
|
34251
|
-
*/
|
|
34252
|
-
/**
|
|
34253
|
-
* An error that is thrown when validation of a schema fails.
|
|
34254
|
-
*
|
|
34255
|
-
* @see {@link ifInvalidThrow} - for throwing errors on invalid input.
|
|
34256
|
-
*/
|
|
34257
|
-
/** @class */ ((function (_super) {
|
|
34258
|
-
__extends(MapperValidationError, _super);
|
|
34259
|
-
function MapperValidationError(errors) {
|
|
34260
|
-
var _this = _super.call(this, 'Validation error mapping object.') || this;
|
|
34261
|
-
_this.errors = errors;
|
|
34262
|
-
Object.setPrototypeOf(_this, MapperValidationError.prototype);
|
|
34263
|
-
return _this;
|
|
34264
|
-
}
|
|
34265
|
-
return MapperValidationError;
|
|
34266
|
-
})(Error));
|
|
34267
|
-
|
|
34268
|
-
var EventDispatcher = /** @class */ (function () {
|
|
34269
|
-
function EventDispatcher() {
|
|
34109
|
+
class EventDispatcher {
|
|
34110
|
+
constructor() {
|
|
34270
34111
|
this.listeners = [];
|
|
34271
34112
|
}
|
|
34272
|
-
|
|
34273
|
-
var _this = this;
|
|
34113
|
+
on(listener, opts = {}) {
|
|
34274
34114
|
var _a;
|
|
34275
|
-
if (opts === void 0) { opts = {}; }
|
|
34276
34115
|
this.listeners.push(listener);
|
|
34277
|
-
|
|
34278
|
-
controller.signal.addEventListener('abort',
|
|
34279
|
-
(_a = opts.abort) === null || _a === void 0 ? void 0 : _a.addEventListener('abort',
|
|
34280
|
-
return { dispose:
|
|
34281
|
-
}
|
|
34282
|
-
|
|
34283
|
-
|
|
34284
|
-
|
|
34285
|
-
return new Promise(function (resolve) {
|
|
34286
|
-
var subscription = _this.on(function (event) {
|
|
34116
|
+
const controller = new AbortController();
|
|
34117
|
+
controller.signal.addEventListener('abort', () => this.off(listener));
|
|
34118
|
+
(_a = opts.abort) === null || _a === void 0 ? void 0 : _a.addEventListener('abort', () => controller.abort());
|
|
34119
|
+
return { dispose: () => controller.abort() };
|
|
34120
|
+
}
|
|
34121
|
+
once(opts = {}) {
|
|
34122
|
+
return new Promise((resolve) => {
|
|
34123
|
+
const subscription = this.on((event) => {
|
|
34287
34124
|
subscription.dispose();
|
|
34288
34125
|
resolve(event);
|
|
34289
34126
|
}, opts);
|
|
34290
34127
|
});
|
|
34291
|
-
}
|
|
34292
|
-
|
|
34293
|
-
|
|
34294
|
-
|
|
34295
|
-
|
|
34296
|
-
|
|
34297
|
-
|
|
34298
|
-
|
|
34299
|
-
|
|
34300
|
-
|
|
34301
|
-
|
|
34302
|
-
|
|
34303
|
-
if (predicate(event)) {
|
|
34304
|
-
controller.abort();
|
|
34305
|
-
resolve(event);
|
|
34306
|
-
}
|
|
34307
|
-
}, __assign(__assign({}, opts), { abort: controller.signal }));
|
|
34308
|
-
})];
|
|
34309
|
-
});
|
|
34128
|
+
}
|
|
34129
|
+
async onceWhen(predicate, opts = {}) {
|
|
34130
|
+
var _a;
|
|
34131
|
+
const controller = new AbortController();
|
|
34132
|
+
(_a = opts.abort) === null || _a === void 0 ? void 0 : _a.addEventListener('abort', () => controller.abort());
|
|
34133
|
+
return new Promise((resolve) => {
|
|
34134
|
+
this.when(predicate, (event) => {
|
|
34135
|
+
if (predicate(event)) {
|
|
34136
|
+
controller.abort();
|
|
34137
|
+
resolve(event);
|
|
34138
|
+
}
|
|
34139
|
+
}, { ...opts, abort: controller.signal });
|
|
34310
34140
|
});
|
|
34311
|
-
}
|
|
34312
|
-
|
|
34313
|
-
|
|
34314
|
-
return this.on(function (event) {
|
|
34141
|
+
}
|
|
34142
|
+
when(predicate, listener, opts = {}) {
|
|
34143
|
+
return this.on((event) => {
|
|
34315
34144
|
if (predicate(event)) {
|
|
34316
34145
|
listener(event);
|
|
34317
34146
|
}
|
|
34318
34147
|
}, opts);
|
|
34319
|
-
}
|
|
34320
|
-
|
|
34321
|
-
|
|
34148
|
+
}
|
|
34149
|
+
off(listener) {
|
|
34150
|
+
const index = this.listeners.indexOf(listener);
|
|
34322
34151
|
if (index !== -1) {
|
|
34323
34152
|
this.listeners.splice(index, 1);
|
|
34324
34153
|
}
|
|
34325
|
-
}
|
|
34326
|
-
|
|
34327
|
-
this.listeners.forEach(
|
|
34328
|
-
}
|
|
34329
|
-
|
|
34330
|
-
}());
|
|
34154
|
+
}
|
|
34155
|
+
emit(event) {
|
|
34156
|
+
this.listeners.forEach((listener) => listener(event));
|
|
34157
|
+
}
|
|
34158
|
+
}
|
|
34331
34159
|
|
|
34332
34160
|
const MAX_ZOOM_PERCENTAGE = 600;
|
|
34333
34161
|
const MIN_ZOOM_PERCENTAGE = 10;
|
|
@@ -34524,7 +34352,7 @@ class PdfJsRenderer extends DocumentRenderer {
|
|
|
34524
34352
|
this.state = { pages: {}, rendering: false };
|
|
34525
34353
|
// Render pages using an offscreen canvas to avoid flickering that can occur for
|
|
34526
34354
|
// PDFs with annotations.
|
|
34527
|
-
this.offscreenCanvas =
|
|
34355
|
+
this.offscreenCanvas = createElement('canvas');
|
|
34528
34356
|
this.handleStateChanged = this.handleStateChanged.bind(this);
|
|
34529
34357
|
this.stateChangedDisposable = this.api.onStateChanged(this.handleStateChanged);
|
|
34530
34358
|
}
|
|
@@ -34566,10 +34394,18 @@ class PdfJsRenderer extends DocumentRenderer {
|
|
|
34566
34394
|
});
|
|
34567
34395
|
this.offscreenCanvas.width = this.canvas.width;
|
|
34568
34396
|
this.offscreenCanvas.height = this.canvas.height;
|
|
34397
|
+
const offscreenCanvasCtx = this.offscreenCanvas.getContext('2d');
|
|
34398
|
+
// Fill the offscreen canvas with a white background prior to rendering the page to give the content
|
|
34399
|
+
// of the PDF a white background, but maintain the canvas it gets drawn to when copying to the main canvas.
|
|
34400
|
+
if (offscreenCanvasCtx != null) {
|
|
34401
|
+
offscreenCanvasCtx.fillStyle = '#ffffff';
|
|
34402
|
+
offscreenCanvasCtx.fillRect(panOffset.x + centerOffsetX, panOffset.y, scaled.width, scaled.height);
|
|
34403
|
+
}
|
|
34569
34404
|
await page.render({
|
|
34570
34405
|
canvas: this.offscreenCanvas,
|
|
34571
34406
|
viewport: scaled,
|
|
34572
34407
|
intent: 'display',
|
|
34408
|
+
background: 'transparent',
|
|
34573
34409
|
optionalContentConfigPromise: optionalContentConfig != null ? Promise.resolve(optionalContentConfig) : undefined,
|
|
34574
34410
|
}).promise;
|
|
34575
34411
|
// Emit an event before the page is drawn, then draw the page to the canvas on the next
|
|
@@ -34599,7 +34435,7 @@ class PdfJsProvider {
|
|
|
34599
34435
|
}
|
|
34600
34436
|
}
|
|
34601
34437
|
|
|
34602
|
-
const documentViewerCss = () => `:host{display:block;position:relative;width:300px;height:300px;min-width:1px;min-height:1px;user-select:none;-webkit-user-select:none}.viewer-container{width:100%;height:100%;overflow:hidden}.canvas-container{display:flex;justify-content:center;align-items:center;width:100%;height:100%;position:relative}`;
|
|
34438
|
+
const documentViewerCss = () => `:host{display:block;position:relative;width:300px;height:300px;min-width:1px;min-height:1px;user-select:none;-webkit-user-select:none;--viewer-background:#eeeeee}.viewer-container{width:100%;height:100%;overflow:hidden}.canvas-container{display:flex;justify-content:center;align-items:center;width:100%;height:100%;position:relative}#document-viewer-canvas{background-color:var(--viewer-background)}`;
|
|
34603
34439
|
|
|
34604
34440
|
const VertexDocumentViewer = class {
|
|
34605
34441
|
constructor(hostRef) {
|
|
@@ -34631,6 +34467,7 @@ const VertexDocumentViewer = class {
|
|
|
34631
34467
|
this.handleDocumentApiStateChanged = this.handleDocumentApiStateChanged.bind(this);
|
|
34632
34468
|
this.handlePageLoaded = this.handlePageLoaded.bind(this);
|
|
34633
34469
|
this.handlePageDrawn = this.handlePageDrawn.bind(this);
|
|
34470
|
+
this.layers = new DocumentLayersController();
|
|
34634
34471
|
this.resizeObserver = new ResizeObserver(this.handleElementResize);
|
|
34635
34472
|
this.registerSlotChangeListeners();
|
|
34636
34473
|
}
|
|
@@ -34643,7 +34480,7 @@ const VertexDocumentViewer = class {
|
|
|
34643
34480
|
var _a;
|
|
34644
34481
|
(_a = this.resizeObserver) === null || _a === void 0 ? void 0 : _a.observe(this.hostEl);
|
|
34645
34482
|
this.updateComponentDimensions();
|
|
34646
|
-
this.
|
|
34483
|
+
this.loadInitialSrc();
|
|
34647
34484
|
this.injectViewerApi();
|
|
34648
34485
|
}
|
|
34649
34486
|
disconnectedCallback() {
|
|
@@ -34710,12 +34547,13 @@ const VertexDocumentViewer = class {
|
|
|
34710
34547
|
await documentApi.loadPage(pageNumber);
|
|
34711
34548
|
}
|
|
34712
34549
|
async handleSrcChange() {
|
|
34550
|
+
var _a;
|
|
34713
34551
|
if (this.src != null && this.canvasEl != null) {
|
|
34714
34552
|
this.clearCurrentDocument();
|
|
34715
34553
|
const { api, renderer } = this.provider.create(this.canvasEl, this.config);
|
|
34716
34554
|
this.documentApi = api;
|
|
34717
34555
|
this.documentRenderer = renderer;
|
|
34718
|
-
this.layers
|
|
34556
|
+
(_a = this.layers) === null || _a === void 0 ? void 0 : _a.setApi(api);
|
|
34719
34557
|
this.updateInteractionHandler();
|
|
34720
34558
|
this.updateDocumentApiListeners();
|
|
34721
34559
|
await this.documentApi.updateViewport(this.dimensions);
|
|
@@ -34732,9 +34570,9 @@ const VertexDocumentViewer = class {
|
|
|
34732
34570
|
this.updateInteractionHandler();
|
|
34733
34571
|
}
|
|
34734
34572
|
render() {
|
|
34735
|
-
return (h(Host, { key: '
|
|
34573
|
+
return (h(Host, { key: 'a990831d5f2328f2cf21be0b82d4018b05decd51' }, h("div", { key: '349abae36254da570e640417fab459680c576465', ref: ref => (this.viewerContainerElement = ref), class: "viewer-container", onContextMenu: event => event.preventDefault() }, h("div", { key: '6fca3f1d5a2c31bdcc0c8dbbd468e306db981740', ref: ref => (this.canvasContainerElement = ref), class: classNames('canvas-container', {
|
|
34736
34574
|
'enable-pointer-events ': window.PointerEvent != null,
|
|
34737
|
-
}) }, h("canvas", { key: '
|
|
34575
|
+
}) }, h("canvas", { key: 'deb1c58d8d20000053cd829401163bf1e68ca88e', id: "document-viewer-canvas", role: "presentation", ref: el => (this.canvasEl = el) })), h("slot", { key: '6b87846ef17b330b0fae5d03103765bad6fdafa6' }))));
|
|
34738
34576
|
}
|
|
34739
34577
|
getDocumentApi() {
|
|
34740
34578
|
if (this.documentApi == null) {
|
|
@@ -34742,15 +34580,25 @@ const VertexDocumentViewer = class {
|
|
|
34742
34580
|
}
|
|
34743
34581
|
return this.documentApi;
|
|
34744
34582
|
}
|
|
34583
|
+
async loadInitialSrc() {
|
|
34584
|
+
await Promise.resolve();
|
|
34585
|
+
await this.handleSrcChange();
|
|
34586
|
+
}
|
|
34745
34587
|
clearCurrentDocument() {
|
|
34746
|
-
var _a, _b, _c, _d, _e, _f;
|
|
34588
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
34747
34589
|
(_a = this.documentRenderer) === null || _a === void 0 ? void 0 : _a.dispose();
|
|
34748
34590
|
(_b = this.documentApi) === null || _b === void 0 ? void 0 : _b.dispose();
|
|
34749
34591
|
(_c = this.panInteractionHandler) === null || _c === void 0 ? void 0 : _c.dispose();
|
|
34750
34592
|
(_d = this.documentApiStateChangedDisposable) === null || _d === void 0 ? void 0 : _d.dispose();
|
|
34751
34593
|
(_e = this.pageLoadedDisposable) === null || _e === void 0 ? void 0 : _e.dispose();
|
|
34752
34594
|
(_f = this.pageDrawnDisposable) === null || _f === void 0 ? void 0 : _f.dispose();
|
|
34753
|
-
this.
|
|
34595
|
+
this.documentRenderer = undefined;
|
|
34596
|
+
this.documentApi = undefined;
|
|
34597
|
+
this.panInteractionHandler = undefined;
|
|
34598
|
+
this.documentApiStateChangedDisposable = undefined;
|
|
34599
|
+
this.pageLoadedDisposable = undefined;
|
|
34600
|
+
this.pageDrawnDisposable = undefined;
|
|
34601
|
+
(_g = this.layers) === null || _g === void 0 ? void 0 : _g.clear();
|
|
34754
34602
|
}
|
|
34755
34603
|
handleDocumentApiStateChanged(state) {
|
|
34756
34604
|
this.documentState = state;
|