@vertexvis/doc-viewer 1.0.2-testing.3 → 1.0.2-testing.5

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.
Files changed (32) hide show
  1. package/dist/cjs/vertex-document-viewer.cjs.entry.js +112 -275
  2. package/dist/collection/components/document-viewer/document-viewer.css +2 -2
  3. package/dist/collection/components/document-viewer/document-viewer.js +18 -6
  4. package/dist/collection/lib/document/layers/controller.js +12 -0
  5. package/dist/components/vertex-document-viewer.js +2 -2
  6. package/dist/doc-viewer/doc-viewer.esm.js +1 -1
  7. package/dist/doc-viewer/p-49c08e34.entry.js +25 -0
  8. package/dist/esm/vertex-document-viewer.entry.js +112 -275
  9. package/dist/types/__mocks__/pdfjs-mock.d.ts +1 -0
  10. package/dist/types/__setup__/polyfills.d.ts +1 -0
  11. package/dist/types/__setup__/resize-observer.d.ts +1 -0
  12. package/dist/types/components/document-viewer/document-viewer.d.ts +2 -0
  13. package/dist/types/index.d.ts +1 -0
  14. package/dist/types/lib/config.d.ts +1 -0
  15. package/dist/types/lib/document/api.d.ts +1 -0
  16. package/dist/types/lib/document/layers/controller.d.ts +4 -1
  17. package/dist/types/lib/document/layers/index.d.ts +1 -0
  18. package/dist/types/lib/document/layers/types.d.ts +1 -0
  19. package/dist/types/lib/document/provider.d.ts +1 -0
  20. package/dist/types/lib/document/renderer.d.ts +1 -0
  21. package/dist/types/lib/dom.d.ts +1 -0
  22. package/dist/types/lib/index.d.ts +1 -0
  23. package/dist/types/lib/interactions/pan-interaction-handler.d.ts +1 -0
  24. package/dist/types/lib/pdf/pdfjs-api.d.ts +1 -0
  25. package/dist/types/lib/pdf/pdfjs-provider.d.ts +1 -0
  26. package/dist/types/lib/pdf/pdfjs-renderer.d.ts +1 -0
  27. package/dist/types/lib/types/loadableResource.d.ts +1 -0
  28. package/dist/types/polyfill/index.d.ts +1 -0
  29. package/dist/types/polyfill/resize-observer.d.ts +1 -0
  30. package/dist/types/testing/mock-document-api.d.ts +1 -0
  31. package/package.json +6 -6
  32. package/dist/doc-viewer/p-96109c78.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
- if (x === void 0) { x = 0; }
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
- var x = Math.cos(radians) * length;
155
- var y = Math.sin(radians) * length;
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
- var delta = subtract$1(a, b);
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
- var magnitudeOfPoint = magnitude$2(pt);
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
- var unitVectorBetweenPoints = normalDirectionVector(ptA, ptB);
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
- var vectorXValue = 1 - Math.pow(unitVectorBetweenPoints.x, 2);
259
- var vectorYValue = -1 * unitVectorBetweenPoints.x * unitVectorBetweenPoints.y;
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
- var vectorXValue = -1 * unitVectorBetweenPoints.x * unitVectorBetweenPoints.y;
264
- var vectorYValue = 1 - Math.pow(unitVectorBetweenPoints.y, 2);
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
- var obj = JSON.parse(json);
188
+ const obj = JSON.parse(json);
276
189
  if (Array.isArray(obj)) {
277
- var x = obj[0], y = obj[1];
190
+ const [x, y] = obj;
278
191
  return create$d(x, y);
279
192
  }
280
193
  else {
281
- var x = obj.x, y = obj.y;
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: x, y: y, width: width, height: height };
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
- var scale = Math.min(to.width / rect.width, to.height / rect.height);
327
- var dimensions$1 = proportionalScale(scale, rect);
328
- var position = subtract$1(center$2(to), center$1(dimensions$1));
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
- var scale = Math.max(to.width / rect.width, to.height / rect.height);
341
- var dimensions$1 = proportionalScale(scale, rect);
342
- var position = subtract$1(center$2(to), center$1(dimensions$1));
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
- var scale = Math.min(Math.sqrt(to / area$1(rect)), 1);
355
- var dimensions$1 = floor$1(proportionalScale(scale, rect));
356
- var position = subtract$1(center$2(rect), center$1(dimensions$1));
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
- var create$6 = function (width, height) {
377
- return { width: width, height: height };
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
- var square = function (size) {
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
- var isEqual = function (a, b) {
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
- var scale = function (scaleX, scaleY, dimensions) {
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
- var proportionalScale = function (scaleFactor, dimensions) {
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
- var trim = function (to, dimensions) {
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
- var containFit = function (to, dimensions) {
426
- var _a = containFit$1(toRectangle(to), toRectangle(dimensions)), width = _a.width, height = _a.height;
427
- return { width: width, height: height };
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
- var cropFit = function (to, dimensions) {
437
- var _a = cropFit$1(toRectangle(to), toRectangle(dimensions)), width = _a.width, height = _a.height;
438
- return { width: width, height: height };
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
- var scaleFit = function (to, dimensions) {
449
- var _a = scaleFit$1(to, toRectangle(dimensions)), width = _a.width, height = _a.height;
450
- return { width: width, height: height };
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
- var round = function (dimensions) {
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
- var floor$1 = function (dimensions) {
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
- var center$1 = function (dimensions) {
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
- var aspectRatio = function (_a) {
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
- var area = function (_a) {
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
- var fitToRatio = function (ratio, dimensions) {
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.
@@ -34205,153 +34127,56 @@ globalThis.pdfjsLib = {
34205
34127
  XfaLayer: XfaLayer
34206
34128
  };
34207
34129
 
34208
- /**
34209
- * A module for defining functional schemas to map between different types. This
34210
- * module is useful for parsing to or from JSON/protobufs to domain types.
34211
- *
34212
- * Mappers support greedy validation, so all validation errors are aggregated
34213
- * and reported vs failing on the first invalid input.
34214
- *
34215
- * @example
34216
- *
34217
- * ```ts
34218
- * import { Mapper as M } from '@vertexvis/utils';
34219
- *
34220
- * interface Address {
34221
- * address: string;
34222
- * city: string;
34223
- * state: string;
34224
- * zip: string;
34225
- * }
34226
- *
34227
- * interface Person {
34228
- * name: string;
34229
- * addresses: Address[];
34230
- * }
34231
- *
34232
- * type AddressJson = Partial<Address>;
34233
- * type PersonJson = {
34234
- * name?: string;
34235
- * addresses?: AddressJson[];
34236
- * }
34237
- *
34238
- * const mapAddress: M.Func<AddressJson, Address> = M.defineMapper(
34239
- * M.read(
34240
- * M.requireProp('address'),
34241
- * M.requireProp('city'),
34242
- * M.requireProp('state'),
34243
- * M.requireProp('zip')
34244
- * ),
34245
- * ([address, city, state, zip]) => ({
34246
- * address, city, state, zip
34247
- * })
34248
- * );
34249
- *
34250
- * const mapPerson: M.Func<PersonJson, Person> = M.defineMapper(
34251
- * M.read(
34252
- * M.requireProp('name'),
34253
- * M.mapProp(
34254
- * 'addresses',
34255
- * M.compose(M.required('addresses'), M.mapArray(mapAddress))
34256
- * )
34257
- * ),
34258
- * ([name, addresses]) => ({ name, addresses })
34259
- * );
34260
- *
34261
- * const person = mapPerson({
34262
- * name: 'John',
34263
- * addresses: [{ address: '123', city: 'Ames', state: 'IA', zip: '50010' }]
34264
- * });
34265
- *
34266
- * const invalidPerson = mapPerson({
34267
- * addresses: [{ city: 'Ames', state: 'IA', zip: '50010' }]
34268
- * });
34269
- * ```
34270
- * // {
34271
- * // errors: ["Name is required.", "Address is required."]
34272
- * // }
34273
- *
34274
- * @module
34275
- */
34276
- /**
34277
- * An error that is thrown when validation of a schema fails.
34278
- *
34279
- * @see {@link ifInvalidThrow} - for throwing errors on invalid input.
34280
- */
34281
- /** @class */ ((function (_super) {
34282
- __extends(MapperValidationError, _super);
34283
- function MapperValidationError(errors) {
34284
- var _this = _super.call(this, 'Validation error mapping object.') || this;
34285
- _this.errors = errors;
34286
- Object.setPrototypeOf(_this, MapperValidationError.prototype);
34287
- return _this;
34288
- }
34289
- return MapperValidationError;
34290
- })(Error));
34291
-
34292
- var EventDispatcher = /** @class */ (function () {
34293
- function EventDispatcher() {
34130
+ class EventDispatcher {
34131
+ constructor() {
34294
34132
  this.listeners = [];
34295
34133
  }
34296
- EventDispatcher.prototype.on = function (listener, opts) {
34297
- var _this = this;
34134
+ on(listener, opts = {}) {
34298
34135
  var _a;
34299
- if (opts === void 0) { opts = {}; }
34300
34136
  this.listeners.push(listener);
34301
- var controller = new AbortController();
34302
- controller.signal.addEventListener('abort', function () { return _this.off(listener); });
34303
- (_a = opts.abort) === null || _a === void 0 ? void 0 : _a.addEventListener('abort', function () { return controller.abort(); });
34304
- return { dispose: function () { return controller.abort(); } };
34305
- };
34306
- EventDispatcher.prototype.once = function (opts) {
34307
- var _this = this;
34308
- if (opts === void 0) { opts = {}; }
34309
- return new Promise(function (resolve) {
34310
- 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) => {
34311
34145
  subscription.dispose();
34312
34146
  resolve(event);
34313
34147
  }, opts);
34314
34148
  });
34315
- };
34316
- EventDispatcher.prototype.onceWhen = function (predicate_1) {
34317
- return __awaiter(this, arguments, Promise, function (predicate, opts) {
34318
- var controller;
34319
- var _this = this;
34320
- var _a;
34321
- if (opts === void 0) { opts = {}; }
34322
- return __generator(this, function (_b) {
34323
- controller = new AbortController();
34324
- (_a = opts.abort) === null || _a === void 0 ? void 0 : _a.addEventListener('abort', function () { return controller.abort(); });
34325
- return [2 /*return*/, new Promise(function (resolve) {
34326
- _this.when(predicate, function (event) {
34327
- if (predicate(event)) {
34328
- controller.abort();
34329
- resolve(event);
34330
- }
34331
- }, __assign(__assign({}, opts), { abort: controller.signal }));
34332
- })];
34333
- });
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 });
34334
34161
  });
34335
- };
34336
- EventDispatcher.prototype.when = function (predicate, listener, opts) {
34337
- if (opts === void 0) { opts = {}; }
34338
- return this.on(function (event) {
34162
+ }
34163
+ when(predicate, listener, opts = {}) {
34164
+ return this.on((event) => {
34339
34165
  if (predicate(event)) {
34340
34166
  listener(event);
34341
34167
  }
34342
34168
  }, opts);
34343
- };
34344
- EventDispatcher.prototype.off = function (listener) {
34345
- var index = this.listeners.indexOf(listener);
34169
+ }
34170
+ off(listener) {
34171
+ const index = this.listeners.indexOf(listener);
34346
34172
  if (index !== -1) {
34347
34173
  this.listeners.splice(index, 1);
34348
34174
  }
34349
- };
34350
- EventDispatcher.prototype.emit = function (event) {
34351
- this.listeners.forEach(function (listener) { return listener(event); });
34352
- };
34353
- return EventDispatcher;
34354
- }());
34175
+ }
34176
+ emit(event) {
34177
+ this.listeners.forEach((listener) => listener(event));
34178
+ }
34179
+ }
34355
34180
 
34356
34181
  const MAX_ZOOM_PERCENTAGE = 600;
34357
34182
  const MIN_ZOOM_PERCENTAGE = 10;
@@ -34631,7 +34456,7 @@ class PdfJsProvider {
34631
34456
  }
34632
34457
  }
34633
34458
 
34634
- 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:#cccccc}.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)}`;
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)}`;
34635
34460
 
34636
34461
  const VertexDocumentViewer = class {
34637
34462
  constructor(hostRef) {
@@ -34663,6 +34488,7 @@ const VertexDocumentViewer = class {
34663
34488
  this.handleDocumentApiStateChanged = this.handleDocumentApiStateChanged.bind(this);
34664
34489
  this.handlePageLoaded = this.handlePageLoaded.bind(this);
34665
34490
  this.handlePageDrawn = this.handlePageDrawn.bind(this);
34491
+ this.layers = new DocumentLayersController();
34666
34492
  this.resizeObserver = new ResizeObserver(this.handleElementResize);
34667
34493
  this.registerSlotChangeListeners();
34668
34494
  }
@@ -34675,7 +34501,7 @@ const VertexDocumentViewer = class {
34675
34501
  var _a;
34676
34502
  (_a = this.resizeObserver) === null || _a === void 0 ? void 0 : _a.observe(this.hostEl);
34677
34503
  this.updateComponentDimensions();
34678
- this.handleSrcChange();
34504
+ this.loadInitialSrc();
34679
34505
  this.injectViewerApi();
34680
34506
  }
34681
34507
  disconnectedCallback() {
@@ -34742,12 +34568,13 @@ const VertexDocumentViewer = class {
34742
34568
  await documentApi.loadPage(pageNumber);
34743
34569
  }
34744
34570
  async handleSrcChange() {
34571
+ var _a;
34745
34572
  if (this.src != null && this.canvasEl != null) {
34746
34573
  this.clearCurrentDocument();
34747
34574
  const { api, renderer } = this.provider.create(this.canvasEl, this.config);
34748
34575
  this.documentApi = api;
34749
34576
  this.documentRenderer = renderer;
34750
- this.layers = new DocumentLayersController(api);
34577
+ (_a = this.layers) === null || _a === void 0 ? void 0 : _a.setApi(api);
34751
34578
  this.updateInteractionHandler();
34752
34579
  this.updateDocumentApiListeners();
34753
34580
  await this.documentApi.updateViewport(this.dimensions);
@@ -34764,9 +34591,9 @@ const VertexDocumentViewer = class {
34764
34591
  this.updateInteractionHandler();
34765
34592
  }
34766
34593
  render() {
34767
- return (index.h(index.Host, { key: 'f1ddf0b4e321bc244a5d757e48f6d71c23caca3c' }, index.h("div", { key: '174c64c537f4b0f1c45fc6543e5b7f54515e4063', ref: ref => (this.viewerContainerElement = ref), class: "viewer-container", onContextMenu: event => event.preventDefault() }, index.h("div", { key: '4c47dadba03b32bde017252a9a8ea7f6e6d323f3', ref: ref => (this.canvasContainerElement = ref), class: classNames('canvas-container', {
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', {
34768
34595
  'enable-pointer-events ': window.PointerEvent != null,
34769
- }) }, index.h("canvas", { key: 'ae645889dd5cb93084f820f9f3d14a56de0213f7', id: "document-viewer-canvas", role: "presentation", ref: el => (this.canvasEl = el) })), index.h("slot", { key: '7762c493306bf5d21cd16218f1abd3c6d0300ace' }))));
34596
+ }) }, index.h("canvas", { key: 'deb1c58d8d20000053cd829401163bf1e68ca88e', id: "document-viewer-canvas", role: "presentation", ref: el => (this.canvasEl = el) })), index.h("slot", { key: '6b87846ef17b330b0fae5d03103765bad6fdafa6' }))));
34770
34597
  }
34771
34598
  getDocumentApi() {
34772
34599
  if (this.documentApi == null) {
@@ -34774,15 +34601,25 @@ const VertexDocumentViewer = class {
34774
34601
  }
34775
34602
  return this.documentApi;
34776
34603
  }
34604
+ async loadInitialSrc() {
34605
+ await Promise.resolve();
34606
+ await this.handleSrcChange();
34607
+ }
34777
34608
  clearCurrentDocument() {
34778
- var _a, _b, _c, _d, _e, _f;
34609
+ var _a, _b, _c, _d, _e, _f, _g;
34779
34610
  (_a = this.documentRenderer) === null || _a === void 0 ? void 0 : _a.dispose();
34780
34611
  (_b = this.documentApi) === null || _b === void 0 ? void 0 : _b.dispose();
34781
34612
  (_c = this.panInteractionHandler) === null || _c === void 0 ? void 0 : _c.dispose();
34782
34613
  (_d = this.documentApiStateChangedDisposable) === null || _d === void 0 ? void 0 : _d.dispose();
34783
34614
  (_e = this.pageLoadedDisposable) === null || _e === void 0 ? void 0 : _e.dispose();
34784
34615
  (_f = this.pageDrawnDisposable) === null || _f === void 0 ? void 0 : _f.dispose();
34785
- this.layers = undefined;
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();
34786
34623
  }
34787
34624
  handleDocumentApiStateChanged(state) {
34788
34625
  this.documentState = state;
@@ -12,9 +12,9 @@
12
12
  /**
13
13
  * @prop --viewer-background:
14
14
  * A CSS color value used as the background painted behind the loaded PDF,
15
- * visible in the negative space around the page. Defaults to #cccccc.
15
+ * visible in the negative space around the page. Defaults to #eeeeee.
16
16
  */
17
- --viewer-background: #cccccc;
17
+ --viewer-background: #eeeeee;
18
18
  }
19
19
 
20
20
  .viewer-container {