@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
|
@@ -28,91 +28,6 @@ function getDefaultExportFromCjs (x) {
|
|
|
28
28
|
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
|
|
29
29
|
}
|
|
30
30
|
|
|
31
|
-
/******************************************************************************
|
|
32
|
-
Copyright (c) Microsoft Corporation.
|
|
33
|
-
|
|
34
|
-
Permission to use, copy, modify, and/or distribute this software for any
|
|
35
|
-
purpose with or without fee is hereby granted.
|
|
36
|
-
|
|
37
|
-
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
38
|
-
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
39
|
-
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
40
|
-
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
41
|
-
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
42
|
-
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
43
|
-
PERFORMANCE OF THIS SOFTWARE.
|
|
44
|
-
***************************************************************************** */
|
|
45
|
-
/* global Reflect, Promise, SuppressedError, Symbol, Iterator */
|
|
46
|
-
|
|
47
|
-
var extendStatics = function(d, b) {
|
|
48
|
-
extendStatics = Object.setPrototypeOf ||
|
|
49
|
-
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
50
|
-
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
51
|
-
return extendStatics(d, b);
|
|
52
|
-
};
|
|
53
|
-
|
|
54
|
-
function __extends(d, b) {
|
|
55
|
-
if (typeof b !== "function" && b !== null)
|
|
56
|
-
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
57
|
-
extendStatics(d, b);
|
|
58
|
-
function __() { this.constructor = d; }
|
|
59
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
var __assign = function() {
|
|
63
|
-
__assign = Object.assign || function __assign(t) {
|
|
64
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
65
|
-
s = arguments[i];
|
|
66
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
|
|
67
|
-
}
|
|
68
|
-
return t;
|
|
69
|
-
};
|
|
70
|
-
return __assign.apply(this, arguments);
|
|
71
|
-
};
|
|
72
|
-
|
|
73
|
-
function __awaiter(thisArg, _arguments, P, generator) {
|
|
74
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
75
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
76
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
77
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
78
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
79
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
80
|
-
});
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
function __generator(thisArg, body) {
|
|
84
|
-
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);
|
|
85
|
-
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
86
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
87
|
-
function step(op) {
|
|
88
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
89
|
-
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
90
|
-
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;
|
|
91
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
92
|
-
switch (op[0]) {
|
|
93
|
-
case 0: case 1: t = op; break;
|
|
94
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
95
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
96
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
97
|
-
default:
|
|
98
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
99
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
100
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
101
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
102
|
-
if (t[2]) _.ops.pop();
|
|
103
|
-
_.trys.pop(); continue;
|
|
104
|
-
}
|
|
105
|
-
op = body.call(thisArg, _);
|
|
106
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
107
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
|
|
112
|
-
var e = new Error(message);
|
|
113
|
-
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
114
|
-
};
|
|
115
|
-
|
|
116
31
|
/**
|
|
117
32
|
* Clamps the given value between `min` and `max`.
|
|
118
33
|
*
|
|
@@ -142,24 +57,22 @@ function lerp$2(a, b, t) {
|
|
|
142
57
|
/**
|
|
143
58
|
* Returns a new `Point` with the given horizontal and vertical position.
|
|
144
59
|
*/
|
|
145
|
-
function create$d(x, y) {
|
|
146
|
-
|
|
147
|
-
if (y === void 0) { y = 0; }
|
|
148
|
-
return { x: x, y: y };
|
|
60
|
+
function create$d(x = 0, y = 0) {
|
|
61
|
+
return { x, y };
|
|
149
62
|
}
|
|
150
63
|
/**
|
|
151
64
|
* Converts a polar coordinate (length and angle) into a Cartesian coordinate.
|
|
152
65
|
*/
|
|
153
66
|
function polar(length, radians) {
|
|
154
|
-
|
|
155
|
-
|
|
67
|
+
const x = Math.cos(radians) * length;
|
|
68
|
+
const y = Math.sin(radians) * length;
|
|
156
69
|
return create$d(x, y);
|
|
157
70
|
}
|
|
158
71
|
/**
|
|
159
72
|
* Returns the distance between two points.
|
|
160
73
|
*/
|
|
161
74
|
function distance$2(a, b) {
|
|
162
|
-
|
|
75
|
+
const delta = subtract$1(a, b);
|
|
163
76
|
return Math.sqrt(delta.x * delta.x + delta.y * delta.y);
|
|
164
77
|
}
|
|
165
78
|
/**
|
|
@@ -231,7 +144,7 @@ function magnitude$2(pt) {
|
|
|
231
144
|
* Transforms a vector into the corresponding normal (unit) vector.
|
|
232
145
|
*/
|
|
233
146
|
function normalizeVector(pt) {
|
|
234
|
-
|
|
147
|
+
const magnitudeOfPoint = magnitude$2(pt);
|
|
235
148
|
if (magnitudeOfPoint === 0) {
|
|
236
149
|
return create$d(0, 0);
|
|
237
150
|
}
|
|
@@ -249,19 +162,19 @@ function normalDirectionVector(ptA, ptB) {
|
|
|
249
162
|
* Returns a vector orthogonal to the vector between the two given points.
|
|
250
163
|
*/
|
|
251
164
|
function orthogonalVector(ptA, ptB) {
|
|
252
|
-
|
|
165
|
+
const unitVectorBetweenPoints = normalDirectionVector(ptA, ptB);
|
|
253
166
|
// Handle vectors that are parallel to the x or y axis
|
|
254
167
|
if (unitVectorBetweenPoints.x === 0 || unitVectorBetweenPoints.y === 0) {
|
|
255
168
|
return create$d(-1 * unitVectorBetweenPoints.y, unitVectorBetweenPoints.x);
|
|
256
169
|
}
|
|
257
170
|
if (Math.abs(unitVectorBetweenPoints.x) > Math.abs(unitVectorBetweenPoints.y)) {
|
|
258
|
-
|
|
259
|
-
|
|
171
|
+
const vectorXValue = 1 - Math.pow(unitVectorBetweenPoints.x, 2);
|
|
172
|
+
const vectorYValue = -1 * unitVectorBetweenPoints.x * unitVectorBetweenPoints.y;
|
|
260
173
|
return normalizeVector(create$d(vectorXValue, vectorYValue));
|
|
261
174
|
}
|
|
262
175
|
else {
|
|
263
|
-
|
|
264
|
-
|
|
176
|
+
const vectorXValue = -1 * unitVectorBetweenPoints.x * unitVectorBetweenPoints.y;
|
|
177
|
+
const vectorYValue = 1 - Math.pow(unitVectorBetweenPoints.y, 2);
|
|
265
178
|
return normalizeVector(create$d(vectorXValue, vectorYValue));
|
|
266
179
|
}
|
|
267
180
|
}
|
|
@@ -272,13 +185,13 @@ function orthogonalVector(ptA, ptB) {
|
|
|
272
185
|
* @returns A parsed Point.
|
|
273
186
|
*/
|
|
274
187
|
function fromJson$5(json) {
|
|
275
|
-
|
|
188
|
+
const obj = JSON.parse(json);
|
|
276
189
|
if (Array.isArray(obj)) {
|
|
277
|
-
|
|
190
|
+
const [x, y] = obj;
|
|
278
191
|
return create$d(x, y);
|
|
279
192
|
}
|
|
280
193
|
else {
|
|
281
|
-
|
|
194
|
+
const { x, y } = obj;
|
|
282
195
|
return create$d(x, y);
|
|
283
196
|
}
|
|
284
197
|
}
|
|
@@ -306,7 +219,7 @@ var point = /*#__PURE__*/Object.freeze({
|
|
|
306
219
|
* Returns a new `Rectangle` with the given position and size.
|
|
307
220
|
*/
|
|
308
221
|
function create$7(x, y, width, height) {
|
|
309
|
-
return { x
|
|
222
|
+
return { x, y, width, height };
|
|
310
223
|
}
|
|
311
224
|
/**
|
|
312
225
|
* Returns a new `Rectangle` with the given position and size.
|
|
@@ -323,9 +236,9 @@ function fromPointAndDimensions(point, dimensions) {
|
|
|
323
236
|
* @see {@link cropFit}
|
|
324
237
|
*/
|
|
325
238
|
function containFit$1(to, rect) {
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
239
|
+
const scale = Math.min(to.width / rect.width, to.height / rect.height);
|
|
240
|
+
const dimensions$1 = proportionalScale(scale, rect);
|
|
241
|
+
const position = subtract$1(center$2(to), center$1(dimensions$1));
|
|
329
242
|
return fromPointAndDimensions(position, dimensions$1);
|
|
330
243
|
}
|
|
331
244
|
/**
|
|
@@ -337,9 +250,9 @@ function containFit$1(to, rect) {
|
|
|
337
250
|
* @see {@link containFit}
|
|
338
251
|
*/
|
|
339
252
|
function cropFit$1(to, rect) {
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
253
|
+
const scale = Math.max(to.width / rect.width, to.height / rect.height);
|
|
254
|
+
const dimensions$1 = proportionalScale(scale, rect);
|
|
255
|
+
const position = subtract$1(center$2(to), center$1(dimensions$1));
|
|
343
256
|
return fromPointAndDimensions(position, dimensions$1);
|
|
344
257
|
}
|
|
345
258
|
/**
|
|
@@ -351,9 +264,9 @@ function cropFit$1(to, rect) {
|
|
|
351
264
|
* @param rect - the rectangle to scale to fit the specified area
|
|
352
265
|
*/
|
|
353
266
|
function scaleFit$1(to, rect) {
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
267
|
+
const scale = Math.min(Math.sqrt(to / area$1(rect)), 1);
|
|
268
|
+
const dimensions$1 = floor$1(proportionalScale(scale, rect));
|
|
269
|
+
const position = subtract$1(center$2(rect), center$1(dimensions$1));
|
|
357
270
|
return fromPointAndDimensions(position, dimensions$1);
|
|
358
271
|
}
|
|
359
272
|
/**
|
|
@@ -373,27 +286,27 @@ function center$2(rect) {
|
|
|
373
286
|
* Returns a `Dimensions` with the given width and height.
|
|
374
287
|
*
|
|
375
288
|
*/
|
|
376
|
-
|
|
377
|
-
return { width
|
|
289
|
+
const create$6 = (width, height) => {
|
|
290
|
+
return { width, height };
|
|
378
291
|
};
|
|
379
292
|
/**
|
|
380
293
|
* Returns a `Dimensions` with the same width and height.
|
|
381
294
|
*/
|
|
382
|
-
|
|
295
|
+
const square = (size) => {
|
|
383
296
|
return create$6(size, size);
|
|
384
297
|
};
|
|
385
298
|
/**
|
|
386
299
|
* Returns `true` if two dimensions have the same width and height. Otherwise
|
|
387
300
|
* `false`.
|
|
388
301
|
*/
|
|
389
|
-
|
|
302
|
+
const isEqual = (a, b) => {
|
|
390
303
|
return a.width === b.width && a.height === b.height;
|
|
391
304
|
};
|
|
392
305
|
/**
|
|
393
306
|
* Returns a scaled dimensions, where the width is scaled by `scaleX` and height
|
|
394
307
|
* is scaled by `scaleY`.
|
|
395
308
|
*/
|
|
396
|
-
|
|
309
|
+
const scale = (scaleX, scaleY, dimensions) => {
|
|
397
310
|
return {
|
|
398
311
|
width: dimensions.width * scaleX,
|
|
399
312
|
height: dimensions.height * scaleY,
|
|
@@ -402,14 +315,14 @@ var scale = function (scaleX, scaleY, dimensions) {
|
|
|
402
315
|
/**
|
|
403
316
|
* Returns a dimension where each length is scaled by `scaleFactor`.
|
|
404
317
|
*/
|
|
405
|
-
|
|
318
|
+
const proportionalScale = (scaleFactor, dimensions) => {
|
|
406
319
|
return scale(scaleFactor, scaleFactor, dimensions);
|
|
407
320
|
};
|
|
408
321
|
/**
|
|
409
322
|
* Returns a `Dimensions` where the lengths of `dimensions` are trimmed to fit
|
|
410
323
|
* into `to`.
|
|
411
324
|
*/
|
|
412
|
-
|
|
325
|
+
const trim = (to, dimensions) => {
|
|
413
326
|
return {
|
|
414
327
|
width: Math.min(to.width, dimensions.width),
|
|
415
328
|
height: Math.min(to.height, dimensions.height),
|
|
@@ -422,9 +335,9 @@ var trim = function (to, dimensions) {
|
|
|
422
335
|
*
|
|
423
336
|
* @see #cropFit()
|
|
424
337
|
*/
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
return { width
|
|
338
|
+
const containFit = (to, dimensions) => {
|
|
339
|
+
const { width, height } = containFit$1(toRectangle(to), toRectangle(dimensions));
|
|
340
|
+
return { width, height };
|
|
428
341
|
};
|
|
429
342
|
/**
|
|
430
343
|
* Returns a `Dimensions` where the shortest length of `dimensions` will be
|
|
@@ -433,9 +346,9 @@ var containFit = function (to, dimensions) {
|
|
|
433
346
|
*
|
|
434
347
|
* @see #containFit()
|
|
435
348
|
*/
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
return { width
|
|
349
|
+
const cropFit = (to, dimensions) => {
|
|
350
|
+
const { width, height } = cropFit$1(toRectangle(to), toRectangle(dimensions));
|
|
351
|
+
return { width, height };
|
|
439
352
|
};
|
|
440
353
|
/**
|
|
441
354
|
* Returns a `Dimensions` where each side of `dimensions` will be reduced proportionally
|
|
@@ -445,14 +358,14 @@ var cropFit = function (to, dimensions) {
|
|
|
445
358
|
* @param to - the maximum area this dimensions can have
|
|
446
359
|
* @param dimensions - the dimensions to scale to fit the specified area
|
|
447
360
|
*/
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
return { width
|
|
361
|
+
const scaleFit = (to, dimensions) => {
|
|
362
|
+
const { width, height } = scaleFit$1(to, toRectangle(dimensions));
|
|
363
|
+
return { width, height };
|
|
451
364
|
};
|
|
452
365
|
/**
|
|
453
366
|
* Returns a `Dimensions` with each length rounded.
|
|
454
367
|
*/
|
|
455
|
-
|
|
368
|
+
const round = (dimensions) => {
|
|
456
369
|
return {
|
|
457
370
|
width: Math.round(dimensions.width),
|
|
458
371
|
height: Math.round(dimensions.height),
|
|
@@ -461,7 +374,7 @@ var round = function (dimensions) {
|
|
|
461
374
|
/**
|
|
462
375
|
* Returns a `Dimensions` with each length rounded down.
|
|
463
376
|
*/
|
|
464
|
-
|
|
377
|
+
const floor$1 = (dimensions) => {
|
|
465
378
|
return {
|
|
466
379
|
width: Math.floor(dimensions.width),
|
|
467
380
|
height: Math.floor(dimensions.height),
|
|
@@ -470,22 +383,20 @@ var floor$1 = function (dimensions) {
|
|
|
470
383
|
/**
|
|
471
384
|
* Returns the center point of the given `dimensions`.
|
|
472
385
|
*/
|
|
473
|
-
|
|
386
|
+
const center$1 = (dimensions) => {
|
|
474
387
|
return { x: dimensions.width / 2, y: dimensions.height / 2 };
|
|
475
388
|
};
|
|
476
389
|
/**
|
|
477
390
|
* Returns the aspect ratio of the given `dimensions`, as defined by width over
|
|
478
391
|
* height.
|
|
479
392
|
*/
|
|
480
|
-
|
|
481
|
-
var width = _a.width, height = _a.height;
|
|
393
|
+
const aspectRatio = ({ width, height }) => {
|
|
482
394
|
return width / height;
|
|
483
395
|
};
|
|
484
396
|
/**
|
|
485
397
|
* Returns the area of the given `dimensions`.
|
|
486
398
|
*/
|
|
487
|
-
|
|
488
|
-
var width = _a.width, height = _a.height;
|
|
399
|
+
const area = ({ width, height }) => {
|
|
489
400
|
return width * height;
|
|
490
401
|
};
|
|
491
402
|
/**
|
|
@@ -494,7 +405,7 @@ var area = function (_a) {
|
|
|
494
405
|
* @param ratio - Aspect ratio to fit the provided Dimensions to
|
|
495
406
|
* @param dimensions - Dimensions to fit to the specified ratio
|
|
496
407
|
*/
|
|
497
|
-
|
|
408
|
+
const fitToRatio = (ratio, dimensions) => {
|
|
498
409
|
if (dimensions.width >= dimensions.height * ratio) {
|
|
499
410
|
return create$6(dimensions.height * ratio, dimensions.height);
|
|
500
411
|
}
|
|
@@ -503,8 +414,7 @@ var fitToRatio = function (ratio, dimensions) {
|
|
|
503
414
|
/**
|
|
504
415
|
* Converts a dimension to a rectangle, with an optional position.
|
|
505
416
|
*/
|
|
506
|
-
function toRectangle(dimensions, position) {
|
|
507
|
-
if (position === void 0) { position = create$d(); }
|
|
417
|
+
function toRectangle(dimensions, position = create$d()) {
|
|
508
418
|
return fromPointAndDimensions(position, dimensions);
|
|
509
419
|
}
|
|
510
420
|
|
|
@@ -625,10 +535,22 @@ function apiSupportsLayers(api) {
|
|
|
625
535
|
class DocumentLayersController {
|
|
626
536
|
constructor(api) {
|
|
627
537
|
this.apiSupportsLayers = false;
|
|
538
|
+
if (api != null) {
|
|
539
|
+
this.setApi(api);
|
|
540
|
+
}
|
|
541
|
+
}
|
|
542
|
+
setApi(api) {
|
|
628
543
|
if (apiSupportsLayers(api)) {
|
|
629
544
|
this.apiSupportsLayers = true;
|
|
630
545
|
this.api = api;
|
|
631
546
|
}
|
|
547
|
+
else {
|
|
548
|
+
this.clear();
|
|
549
|
+
}
|
|
550
|
+
}
|
|
551
|
+
clear() {
|
|
552
|
+
this.apiSupportsLayers = false;
|
|
553
|
+
this.api = undefined;
|
|
632
554
|
}
|
|
633
555
|
/**
|
|
634
556
|
* Returns a boolean indicating whether the document supports layers.
|
|
@@ -663,6 +585,9 @@ class DocumentLayersController {
|
|
|
663
585
|
function getElementBoundingClientRect(element) {
|
|
664
586
|
return element.getBoundingClientRect();
|
|
665
587
|
}
|
|
588
|
+
function createElement(tagName) {
|
|
589
|
+
return document.createElement(tagName);
|
|
590
|
+
}
|
|
666
591
|
function getAllVertexElementChildren(element) {
|
|
667
592
|
return getAllChildren(element)
|
|
668
593
|
.filter(node => node.nodeName.startsWith('VERTEX-'))
|
|
@@ -702,7 +627,7 @@ class PanInteractionHandler {
|
|
|
702
627
|
}
|
|
703
628
|
}
|
|
704
629
|
handlePointerDown(event) {
|
|
705
|
-
if (event.button !==
|
|
630
|
+
if (event.button !== 2) {
|
|
706
631
|
return;
|
|
707
632
|
}
|
|
708
633
|
event.preventDefault();
|
|
@@ -34202,153 +34127,56 @@ globalThis.pdfjsLib = {
|
|
|
34202
34127
|
XfaLayer: XfaLayer
|
|
34203
34128
|
};
|
|
34204
34129
|
|
|
34205
|
-
|
|
34206
|
-
|
|
34207
|
-
* module is useful for parsing to or from JSON/protobufs to domain types.
|
|
34208
|
-
*
|
|
34209
|
-
* Mappers support greedy validation, so all validation errors are aggregated
|
|
34210
|
-
* and reported vs failing on the first invalid input.
|
|
34211
|
-
*
|
|
34212
|
-
* @example
|
|
34213
|
-
*
|
|
34214
|
-
* ```ts
|
|
34215
|
-
* import { Mapper as M } from '@vertexvis/utils';
|
|
34216
|
-
*
|
|
34217
|
-
* interface Address {
|
|
34218
|
-
* address: string;
|
|
34219
|
-
* city: string;
|
|
34220
|
-
* state: string;
|
|
34221
|
-
* zip: string;
|
|
34222
|
-
* }
|
|
34223
|
-
*
|
|
34224
|
-
* interface Person {
|
|
34225
|
-
* name: string;
|
|
34226
|
-
* addresses: Address[];
|
|
34227
|
-
* }
|
|
34228
|
-
*
|
|
34229
|
-
* type AddressJson = Partial<Address>;
|
|
34230
|
-
* type PersonJson = {
|
|
34231
|
-
* name?: string;
|
|
34232
|
-
* addresses?: AddressJson[];
|
|
34233
|
-
* }
|
|
34234
|
-
*
|
|
34235
|
-
* const mapAddress: M.Func<AddressJson, Address> = M.defineMapper(
|
|
34236
|
-
* M.read(
|
|
34237
|
-
* M.requireProp('address'),
|
|
34238
|
-
* M.requireProp('city'),
|
|
34239
|
-
* M.requireProp('state'),
|
|
34240
|
-
* M.requireProp('zip')
|
|
34241
|
-
* ),
|
|
34242
|
-
* ([address, city, state, zip]) => ({
|
|
34243
|
-
* address, city, state, zip
|
|
34244
|
-
* })
|
|
34245
|
-
* );
|
|
34246
|
-
*
|
|
34247
|
-
* const mapPerson: M.Func<PersonJson, Person> = M.defineMapper(
|
|
34248
|
-
* M.read(
|
|
34249
|
-
* M.requireProp('name'),
|
|
34250
|
-
* M.mapProp(
|
|
34251
|
-
* 'addresses',
|
|
34252
|
-
* M.compose(M.required('addresses'), M.mapArray(mapAddress))
|
|
34253
|
-
* )
|
|
34254
|
-
* ),
|
|
34255
|
-
* ([name, addresses]) => ({ name, addresses })
|
|
34256
|
-
* );
|
|
34257
|
-
*
|
|
34258
|
-
* const person = mapPerson({
|
|
34259
|
-
* name: 'John',
|
|
34260
|
-
* addresses: [{ address: '123', city: 'Ames', state: 'IA', zip: '50010' }]
|
|
34261
|
-
* });
|
|
34262
|
-
*
|
|
34263
|
-
* const invalidPerson = mapPerson({
|
|
34264
|
-
* addresses: [{ city: 'Ames', state: 'IA', zip: '50010' }]
|
|
34265
|
-
* });
|
|
34266
|
-
* ```
|
|
34267
|
-
* // {
|
|
34268
|
-
* // errors: ["Name is required.", "Address is required."]
|
|
34269
|
-
* // }
|
|
34270
|
-
*
|
|
34271
|
-
* @module
|
|
34272
|
-
*/
|
|
34273
|
-
/**
|
|
34274
|
-
* An error that is thrown when validation of a schema fails.
|
|
34275
|
-
*
|
|
34276
|
-
* @see {@link ifInvalidThrow} - for throwing errors on invalid input.
|
|
34277
|
-
*/
|
|
34278
|
-
/** @class */ ((function (_super) {
|
|
34279
|
-
__extends(MapperValidationError, _super);
|
|
34280
|
-
function MapperValidationError(errors) {
|
|
34281
|
-
var _this = _super.call(this, 'Validation error mapping object.') || this;
|
|
34282
|
-
_this.errors = errors;
|
|
34283
|
-
Object.setPrototypeOf(_this, MapperValidationError.prototype);
|
|
34284
|
-
return _this;
|
|
34285
|
-
}
|
|
34286
|
-
return MapperValidationError;
|
|
34287
|
-
})(Error));
|
|
34288
|
-
|
|
34289
|
-
var EventDispatcher = /** @class */ (function () {
|
|
34290
|
-
function EventDispatcher() {
|
|
34130
|
+
class EventDispatcher {
|
|
34131
|
+
constructor() {
|
|
34291
34132
|
this.listeners = [];
|
|
34292
34133
|
}
|
|
34293
|
-
|
|
34294
|
-
var _this = this;
|
|
34134
|
+
on(listener, opts = {}) {
|
|
34295
34135
|
var _a;
|
|
34296
|
-
if (opts === void 0) { opts = {}; }
|
|
34297
34136
|
this.listeners.push(listener);
|
|
34298
|
-
|
|
34299
|
-
controller.signal.addEventListener('abort',
|
|
34300
|
-
(_a = opts.abort) === null || _a === void 0 ? void 0 : _a.addEventListener('abort',
|
|
34301
|
-
return { dispose:
|
|
34302
|
-
}
|
|
34303
|
-
|
|
34304
|
-
|
|
34305
|
-
|
|
34306
|
-
return new Promise(function (resolve) {
|
|
34307
|
-
var subscription = _this.on(function (event) {
|
|
34137
|
+
const controller = new AbortController();
|
|
34138
|
+
controller.signal.addEventListener('abort', () => this.off(listener));
|
|
34139
|
+
(_a = opts.abort) === null || _a === void 0 ? void 0 : _a.addEventListener('abort', () => controller.abort());
|
|
34140
|
+
return { dispose: () => controller.abort() };
|
|
34141
|
+
}
|
|
34142
|
+
once(opts = {}) {
|
|
34143
|
+
return new Promise((resolve) => {
|
|
34144
|
+
const subscription = this.on((event) => {
|
|
34308
34145
|
subscription.dispose();
|
|
34309
34146
|
resolve(event);
|
|
34310
34147
|
}, opts);
|
|
34311
34148
|
});
|
|
34312
|
-
}
|
|
34313
|
-
|
|
34314
|
-
|
|
34315
|
-
|
|
34316
|
-
|
|
34317
|
-
|
|
34318
|
-
|
|
34319
|
-
|
|
34320
|
-
|
|
34321
|
-
|
|
34322
|
-
|
|
34323
|
-
|
|
34324
|
-
if (predicate(event)) {
|
|
34325
|
-
controller.abort();
|
|
34326
|
-
resolve(event);
|
|
34327
|
-
}
|
|
34328
|
-
}, __assign(__assign({}, opts), { abort: controller.signal }));
|
|
34329
|
-
})];
|
|
34330
|
-
});
|
|
34149
|
+
}
|
|
34150
|
+
async onceWhen(predicate, opts = {}) {
|
|
34151
|
+
var _a;
|
|
34152
|
+
const controller = new AbortController();
|
|
34153
|
+
(_a = opts.abort) === null || _a === void 0 ? void 0 : _a.addEventListener('abort', () => controller.abort());
|
|
34154
|
+
return new Promise((resolve) => {
|
|
34155
|
+
this.when(predicate, (event) => {
|
|
34156
|
+
if (predicate(event)) {
|
|
34157
|
+
controller.abort();
|
|
34158
|
+
resolve(event);
|
|
34159
|
+
}
|
|
34160
|
+
}, { ...opts, abort: controller.signal });
|
|
34331
34161
|
});
|
|
34332
|
-
}
|
|
34333
|
-
|
|
34334
|
-
|
|
34335
|
-
return this.on(function (event) {
|
|
34162
|
+
}
|
|
34163
|
+
when(predicate, listener, opts = {}) {
|
|
34164
|
+
return this.on((event) => {
|
|
34336
34165
|
if (predicate(event)) {
|
|
34337
34166
|
listener(event);
|
|
34338
34167
|
}
|
|
34339
34168
|
}, opts);
|
|
34340
|
-
}
|
|
34341
|
-
|
|
34342
|
-
|
|
34169
|
+
}
|
|
34170
|
+
off(listener) {
|
|
34171
|
+
const index = this.listeners.indexOf(listener);
|
|
34343
34172
|
if (index !== -1) {
|
|
34344
34173
|
this.listeners.splice(index, 1);
|
|
34345
34174
|
}
|
|
34346
|
-
}
|
|
34347
|
-
|
|
34348
|
-
this.listeners.forEach(
|
|
34349
|
-
}
|
|
34350
|
-
|
|
34351
|
-
}());
|
|
34175
|
+
}
|
|
34176
|
+
emit(event) {
|
|
34177
|
+
this.listeners.forEach((listener) => listener(event));
|
|
34178
|
+
}
|
|
34179
|
+
}
|
|
34352
34180
|
|
|
34353
34181
|
const MAX_ZOOM_PERCENTAGE = 600;
|
|
34354
34182
|
const MIN_ZOOM_PERCENTAGE = 10;
|
|
@@ -34545,7 +34373,7 @@ class PdfJsRenderer extends DocumentRenderer {
|
|
|
34545
34373
|
this.state = { pages: {}, rendering: false };
|
|
34546
34374
|
// Render pages using an offscreen canvas to avoid flickering that can occur for
|
|
34547
34375
|
// PDFs with annotations.
|
|
34548
|
-
this.offscreenCanvas =
|
|
34376
|
+
this.offscreenCanvas = createElement('canvas');
|
|
34549
34377
|
this.handleStateChanged = this.handleStateChanged.bind(this);
|
|
34550
34378
|
this.stateChangedDisposable = this.api.onStateChanged(this.handleStateChanged);
|
|
34551
34379
|
}
|
|
@@ -34587,10 +34415,18 @@ class PdfJsRenderer extends DocumentRenderer {
|
|
|
34587
34415
|
});
|
|
34588
34416
|
this.offscreenCanvas.width = this.canvas.width;
|
|
34589
34417
|
this.offscreenCanvas.height = this.canvas.height;
|
|
34418
|
+
const offscreenCanvasCtx = this.offscreenCanvas.getContext('2d');
|
|
34419
|
+
// Fill the offscreen canvas with a white background prior to rendering the page to give the content
|
|
34420
|
+
// of the PDF a white background, but maintain the canvas it gets drawn to when copying to the main canvas.
|
|
34421
|
+
if (offscreenCanvasCtx != null) {
|
|
34422
|
+
offscreenCanvasCtx.fillStyle = '#ffffff';
|
|
34423
|
+
offscreenCanvasCtx.fillRect(panOffset.x + centerOffsetX, panOffset.y, scaled.width, scaled.height);
|
|
34424
|
+
}
|
|
34590
34425
|
await page.render({
|
|
34591
34426
|
canvas: this.offscreenCanvas,
|
|
34592
34427
|
viewport: scaled,
|
|
34593
34428
|
intent: 'display',
|
|
34429
|
+
background: 'transparent',
|
|
34594
34430
|
optionalContentConfigPromise: optionalContentConfig != null ? Promise.resolve(optionalContentConfig) : undefined,
|
|
34595
34431
|
}).promise;
|
|
34596
34432
|
// Emit an event before the page is drawn, then draw the page to the canvas on the next
|
|
@@ -34620,7 +34456,7 @@ class PdfJsProvider {
|
|
|
34620
34456
|
}
|
|
34621
34457
|
}
|
|
34622
34458
|
|
|
34623
|
-
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}`;
|
|
34459
|
+
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)}`;
|
|
34624
34460
|
|
|
34625
34461
|
const VertexDocumentViewer = class {
|
|
34626
34462
|
constructor(hostRef) {
|
|
@@ -34652,6 +34488,7 @@ const VertexDocumentViewer = class {
|
|
|
34652
34488
|
this.handleDocumentApiStateChanged = this.handleDocumentApiStateChanged.bind(this);
|
|
34653
34489
|
this.handlePageLoaded = this.handlePageLoaded.bind(this);
|
|
34654
34490
|
this.handlePageDrawn = this.handlePageDrawn.bind(this);
|
|
34491
|
+
this.layers = new DocumentLayersController();
|
|
34655
34492
|
this.resizeObserver = new ResizeObserver(this.handleElementResize);
|
|
34656
34493
|
this.registerSlotChangeListeners();
|
|
34657
34494
|
}
|
|
@@ -34664,7 +34501,7 @@ const VertexDocumentViewer = class {
|
|
|
34664
34501
|
var _a;
|
|
34665
34502
|
(_a = this.resizeObserver) === null || _a === void 0 ? void 0 : _a.observe(this.hostEl);
|
|
34666
34503
|
this.updateComponentDimensions();
|
|
34667
|
-
this.
|
|
34504
|
+
this.loadInitialSrc();
|
|
34668
34505
|
this.injectViewerApi();
|
|
34669
34506
|
}
|
|
34670
34507
|
disconnectedCallback() {
|
|
@@ -34731,12 +34568,13 @@ const VertexDocumentViewer = class {
|
|
|
34731
34568
|
await documentApi.loadPage(pageNumber);
|
|
34732
34569
|
}
|
|
34733
34570
|
async handleSrcChange() {
|
|
34571
|
+
var _a;
|
|
34734
34572
|
if (this.src != null && this.canvasEl != null) {
|
|
34735
34573
|
this.clearCurrentDocument();
|
|
34736
34574
|
const { api, renderer } = this.provider.create(this.canvasEl, this.config);
|
|
34737
34575
|
this.documentApi = api;
|
|
34738
34576
|
this.documentRenderer = renderer;
|
|
34739
|
-
this.layers
|
|
34577
|
+
(_a = this.layers) === null || _a === void 0 ? void 0 : _a.setApi(api);
|
|
34740
34578
|
this.updateInteractionHandler();
|
|
34741
34579
|
this.updateDocumentApiListeners();
|
|
34742
34580
|
await this.documentApi.updateViewport(this.dimensions);
|
|
@@ -34753,9 +34591,9 @@ const VertexDocumentViewer = class {
|
|
|
34753
34591
|
this.updateInteractionHandler();
|
|
34754
34592
|
}
|
|
34755
34593
|
render() {
|
|
34756
|
-
return (index.h(index.Host, { key: '
|
|
34594
|
+
return (index.h(index.Host, { key: 'a990831d5f2328f2cf21be0b82d4018b05decd51' }, index.h("div", { key: '349abae36254da570e640417fab459680c576465', ref: ref => (this.viewerContainerElement = ref), class: "viewer-container", onContextMenu: event => event.preventDefault() }, index.h("div", { key: '6fca3f1d5a2c31bdcc0c8dbbd468e306db981740', ref: ref => (this.canvasContainerElement = ref), class: classNames('canvas-container', {
|
|
34757
34595
|
'enable-pointer-events ': window.PointerEvent != null,
|
|
34758
|
-
}) }, index.h("canvas", { key: '
|
|
34596
|
+
}) }, index.h("canvas", { key: 'deb1c58d8d20000053cd829401163bf1e68ca88e', id: "document-viewer-canvas", role: "presentation", ref: el => (this.canvasEl = el) })), index.h("slot", { key: '6b87846ef17b330b0fae5d03103765bad6fdafa6' }))));
|
|
34759
34597
|
}
|
|
34760
34598
|
getDocumentApi() {
|
|
34761
34599
|
if (this.documentApi == null) {
|
|
@@ -34763,15 +34601,25 @@ const VertexDocumentViewer = class {
|
|
|
34763
34601
|
}
|
|
34764
34602
|
return this.documentApi;
|
|
34765
34603
|
}
|
|
34604
|
+
async loadInitialSrc() {
|
|
34605
|
+
await Promise.resolve();
|
|
34606
|
+
await this.handleSrcChange();
|
|
34607
|
+
}
|
|
34766
34608
|
clearCurrentDocument() {
|
|
34767
|
-
var _a, _b, _c, _d, _e, _f;
|
|
34609
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
34768
34610
|
(_a = this.documentRenderer) === null || _a === void 0 ? void 0 : _a.dispose();
|
|
34769
34611
|
(_b = this.documentApi) === null || _b === void 0 ? void 0 : _b.dispose();
|
|
34770
34612
|
(_c = this.panInteractionHandler) === null || _c === void 0 ? void 0 : _c.dispose();
|
|
34771
34613
|
(_d = this.documentApiStateChangedDisposable) === null || _d === void 0 ? void 0 : _d.dispose();
|
|
34772
34614
|
(_e = this.pageLoadedDisposable) === null || _e === void 0 ? void 0 : _e.dispose();
|
|
34773
34615
|
(_f = this.pageDrawnDisposable) === null || _f === void 0 ? void 0 : _f.dispose();
|
|
34774
|
-
this.
|
|
34616
|
+
this.documentRenderer = undefined;
|
|
34617
|
+
this.documentApi = undefined;
|
|
34618
|
+
this.panInteractionHandler = undefined;
|
|
34619
|
+
this.documentApiStateChangedDisposable = undefined;
|
|
34620
|
+
this.pageLoadedDisposable = undefined;
|
|
34621
|
+
this.pageDrawnDisposable = undefined;
|
|
34622
|
+
(_g = this.layers) === null || _g === void 0 ? void 0 : _g.clear();
|
|
34775
34623
|
}
|
|
34776
34624
|
handleDocumentApiStateChanged(state) {
|
|
34777
34625
|
this.documentState = state;
|