@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
@@ -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
- if (x === void 0) { x = 0; }
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
- var x = Math.cos(radians) * length;
134
- var y = Math.sin(radians) * length;
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
- var delta = subtract$1(a, b);
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
- var magnitudeOfPoint = magnitude$2(pt);
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
- var unitVectorBetweenPoints = normalDirectionVector(ptA, ptB);
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
- var vectorXValue = 1 - Math.pow(unitVectorBetweenPoints.x, 2);
238
- var vectorYValue = -1 * unitVectorBetweenPoints.x * unitVectorBetweenPoints.y;
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
- var vectorXValue = -1 * unitVectorBetweenPoints.x * unitVectorBetweenPoints.y;
243
- var vectorYValue = 1 - Math.pow(unitVectorBetweenPoints.y, 2);
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
- var obj = JSON.parse(json);
167
+ const obj = JSON.parse(json);
255
168
  if (Array.isArray(obj)) {
256
- var x = obj[0], y = obj[1];
169
+ const [x, y] = obj;
257
170
  return create$d(x, y);
258
171
  }
259
172
  else {
260
- var x = obj.x, y = obj.y;
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: x, y: y, width: width, height: height };
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
- var scale = Math.min(to.width / rect.width, to.height / rect.height);
306
- var dimensions$1 = proportionalScale(scale, rect);
307
- var position = subtract$1(center$2(to), center$1(dimensions$1));
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
- var scale = Math.max(to.width / rect.width, to.height / rect.height);
320
- var dimensions$1 = proportionalScale(scale, rect);
321
- var position = subtract$1(center$2(to), center$1(dimensions$1));
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
- var scale = Math.min(Math.sqrt(to / area$1(rect)), 1);
334
- var dimensions$1 = floor$1(proportionalScale(scale, rect));
335
- var position = subtract$1(center$2(rect), center$1(dimensions$1));
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
- var create$6 = function (width, height) {
356
- return { width: width, height: height };
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
- var square = function (size) {
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
- var isEqual = function (a, b) {
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
- var scale = function (scaleX, scaleY, dimensions) {
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
- var proportionalScale = function (scaleFactor, dimensions) {
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
- var trim = function (to, dimensions) {
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
- var containFit = function (to, dimensions) {
405
- var _a = containFit$1(toRectangle(to), toRectangle(dimensions)), width = _a.width, height = _a.height;
406
- return { width: width, height: height };
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
- var cropFit = function (to, dimensions) {
416
- var _a = cropFit$1(toRectangle(to), toRectangle(dimensions)), width = _a.width, height = _a.height;
417
- return { width: width, height: height };
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
- var scaleFit = function (to, dimensions) {
428
- var _a = scaleFit$1(to, toRectangle(dimensions)), width = _a.width, height = _a.height;
429
- return { width: width, height: height };
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
- var round = function (dimensions) {
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
- var floor$1 = function (dimensions) {
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
- var center$1 = function (dimensions) {
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
- var aspectRatio = function (_a) {
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
- var area = function (_a) {
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
- var fitToRatio = function (ratio, dimensions) {
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.
@@ -34184,153 +34106,56 @@ globalThis.pdfjsLib = {
34184
34106
  XfaLayer: XfaLayer
34185
34107
  };
34186
34108
 
34187
- /**
34188
- * A module for defining functional schemas to map between different types. This
34189
- * module is useful for parsing to or from JSON/protobufs to domain types.
34190
- *
34191
- * Mappers support greedy validation, so all validation errors are aggregated
34192
- * and reported vs failing on the first invalid input.
34193
- *
34194
- * @example
34195
- *
34196
- * ```ts
34197
- * import { Mapper as M } from '@vertexvis/utils';
34198
- *
34199
- * interface Address {
34200
- * address: string;
34201
- * city: string;
34202
- * state: string;
34203
- * zip: string;
34204
- * }
34205
- *
34206
- * interface Person {
34207
- * name: string;
34208
- * addresses: Address[];
34209
- * }
34210
- *
34211
- * type AddressJson = Partial<Address>;
34212
- * type PersonJson = {
34213
- * name?: string;
34214
- * addresses?: AddressJson[];
34215
- * }
34216
- *
34217
- * const mapAddress: M.Func<AddressJson, Address> = M.defineMapper(
34218
- * M.read(
34219
- * M.requireProp('address'),
34220
- * M.requireProp('city'),
34221
- * M.requireProp('state'),
34222
- * M.requireProp('zip')
34223
- * ),
34224
- * ([address, city, state, zip]) => ({
34225
- * address, city, state, zip
34226
- * })
34227
- * );
34228
- *
34229
- * const mapPerson: M.Func<PersonJson, Person> = M.defineMapper(
34230
- * M.read(
34231
- * M.requireProp('name'),
34232
- * M.mapProp(
34233
- * 'addresses',
34234
- * M.compose(M.required('addresses'), M.mapArray(mapAddress))
34235
- * )
34236
- * ),
34237
- * ([name, addresses]) => ({ name, addresses })
34238
- * );
34239
- *
34240
- * const person = mapPerson({
34241
- * name: 'John',
34242
- * addresses: [{ address: '123', city: 'Ames', state: 'IA', zip: '50010' }]
34243
- * });
34244
- *
34245
- * const invalidPerson = mapPerson({
34246
- * addresses: [{ city: 'Ames', state: 'IA', zip: '50010' }]
34247
- * });
34248
- * ```
34249
- * // {
34250
- * // errors: ["Name is required.", "Address is required."]
34251
- * // }
34252
- *
34253
- * @module
34254
- */
34255
- /**
34256
- * An error that is thrown when validation of a schema fails.
34257
- *
34258
- * @see {@link ifInvalidThrow} - for throwing errors on invalid input.
34259
- */
34260
- /** @class */ ((function (_super) {
34261
- __extends(MapperValidationError, _super);
34262
- function MapperValidationError(errors) {
34263
- var _this = _super.call(this, 'Validation error mapping object.') || this;
34264
- _this.errors = errors;
34265
- Object.setPrototypeOf(_this, MapperValidationError.prototype);
34266
- return _this;
34267
- }
34268
- return MapperValidationError;
34269
- })(Error));
34270
-
34271
- var EventDispatcher = /** @class */ (function () {
34272
- function EventDispatcher() {
34109
+ class EventDispatcher {
34110
+ constructor() {
34273
34111
  this.listeners = [];
34274
34112
  }
34275
- EventDispatcher.prototype.on = function (listener, opts) {
34276
- var _this = this;
34113
+ on(listener, opts = {}) {
34277
34114
  var _a;
34278
- if (opts === void 0) { opts = {}; }
34279
34115
  this.listeners.push(listener);
34280
- var controller = new AbortController();
34281
- controller.signal.addEventListener('abort', function () { return _this.off(listener); });
34282
- (_a = opts.abort) === null || _a === void 0 ? void 0 : _a.addEventListener('abort', function () { return controller.abort(); });
34283
- return { dispose: function () { return controller.abort(); } };
34284
- };
34285
- EventDispatcher.prototype.once = function (opts) {
34286
- var _this = this;
34287
- if (opts === void 0) { opts = {}; }
34288
- return new Promise(function (resolve) {
34289
- 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) => {
34290
34124
  subscription.dispose();
34291
34125
  resolve(event);
34292
34126
  }, opts);
34293
34127
  });
34294
- };
34295
- EventDispatcher.prototype.onceWhen = function (predicate_1) {
34296
- return __awaiter(this, arguments, Promise, function (predicate, opts) {
34297
- var controller;
34298
- var _this = this;
34299
- var _a;
34300
- if (opts === void 0) { opts = {}; }
34301
- return __generator(this, function (_b) {
34302
- controller = new AbortController();
34303
- (_a = opts.abort) === null || _a === void 0 ? void 0 : _a.addEventListener('abort', function () { return controller.abort(); });
34304
- return [2 /*return*/, new Promise(function (resolve) {
34305
- _this.when(predicate, function (event) {
34306
- if (predicate(event)) {
34307
- controller.abort();
34308
- resolve(event);
34309
- }
34310
- }, __assign(__assign({}, opts), { abort: controller.signal }));
34311
- })];
34312
- });
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 });
34313
34140
  });
34314
- };
34315
- EventDispatcher.prototype.when = function (predicate, listener, opts) {
34316
- if (opts === void 0) { opts = {}; }
34317
- return this.on(function (event) {
34141
+ }
34142
+ when(predicate, listener, opts = {}) {
34143
+ return this.on((event) => {
34318
34144
  if (predicate(event)) {
34319
34145
  listener(event);
34320
34146
  }
34321
34147
  }, opts);
34322
- };
34323
- EventDispatcher.prototype.off = function (listener) {
34324
- var index = this.listeners.indexOf(listener);
34148
+ }
34149
+ off(listener) {
34150
+ const index = this.listeners.indexOf(listener);
34325
34151
  if (index !== -1) {
34326
34152
  this.listeners.splice(index, 1);
34327
34153
  }
34328
- };
34329
- EventDispatcher.prototype.emit = function (event) {
34330
- this.listeners.forEach(function (listener) { return listener(event); });
34331
- };
34332
- return EventDispatcher;
34333
- }());
34154
+ }
34155
+ emit(event) {
34156
+ this.listeners.forEach((listener) => listener(event));
34157
+ }
34158
+ }
34334
34159
 
34335
34160
  const MAX_ZOOM_PERCENTAGE = 600;
34336
34161
  const MIN_ZOOM_PERCENTAGE = 10;
@@ -34610,7 +34435,7 @@ class PdfJsProvider {
34610
34435
  }
34611
34436
  }
34612
34437
 
34613
- 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)}`;
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)}`;
34614
34439
 
34615
34440
  const VertexDocumentViewer = class {
34616
34441
  constructor(hostRef) {
@@ -34642,6 +34467,7 @@ const VertexDocumentViewer = class {
34642
34467
  this.handleDocumentApiStateChanged = this.handleDocumentApiStateChanged.bind(this);
34643
34468
  this.handlePageLoaded = this.handlePageLoaded.bind(this);
34644
34469
  this.handlePageDrawn = this.handlePageDrawn.bind(this);
34470
+ this.layers = new DocumentLayersController();
34645
34471
  this.resizeObserver = new ResizeObserver(this.handleElementResize);
34646
34472
  this.registerSlotChangeListeners();
34647
34473
  }
@@ -34654,7 +34480,7 @@ const VertexDocumentViewer = class {
34654
34480
  var _a;
34655
34481
  (_a = this.resizeObserver) === null || _a === void 0 ? void 0 : _a.observe(this.hostEl);
34656
34482
  this.updateComponentDimensions();
34657
- this.handleSrcChange();
34483
+ this.loadInitialSrc();
34658
34484
  this.injectViewerApi();
34659
34485
  }
34660
34486
  disconnectedCallback() {
@@ -34721,12 +34547,13 @@ const VertexDocumentViewer = class {
34721
34547
  await documentApi.loadPage(pageNumber);
34722
34548
  }
34723
34549
  async handleSrcChange() {
34550
+ var _a;
34724
34551
  if (this.src != null && this.canvasEl != null) {
34725
34552
  this.clearCurrentDocument();
34726
34553
  const { api, renderer } = this.provider.create(this.canvasEl, this.config);
34727
34554
  this.documentApi = api;
34728
34555
  this.documentRenderer = renderer;
34729
- this.layers = new DocumentLayersController(api);
34556
+ (_a = this.layers) === null || _a === void 0 ? void 0 : _a.setApi(api);
34730
34557
  this.updateInteractionHandler();
34731
34558
  this.updateDocumentApiListeners();
34732
34559
  await this.documentApi.updateViewport(this.dimensions);
@@ -34743,9 +34570,9 @@ const VertexDocumentViewer = class {
34743
34570
  this.updateInteractionHandler();
34744
34571
  }
34745
34572
  render() {
34746
- return (h(Host, { key: 'f1ddf0b4e321bc244a5d757e48f6d71c23caca3c' }, h("div", { key: '174c64c537f4b0f1c45fc6543e5b7f54515e4063', ref: ref => (this.viewerContainerElement = ref), class: "viewer-container", onContextMenu: event => event.preventDefault() }, h("div", { key: '4c47dadba03b32bde017252a9a8ea7f6e6d323f3', ref: ref => (this.canvasContainerElement = ref), class: classNames('canvas-container', {
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', {
34747
34574
  'enable-pointer-events ': window.PointerEvent != null,
34748
- }) }, h("canvas", { key: 'ae645889dd5cb93084f820f9f3d14a56de0213f7', id: "document-viewer-canvas", role: "presentation", ref: el => (this.canvasEl = el) })), h("slot", { key: '7762c493306bf5d21cd16218f1abd3c6d0300ace' }))));
34575
+ }) }, h("canvas", { key: 'deb1c58d8d20000053cd829401163bf1e68ca88e', id: "document-viewer-canvas", role: "presentation", ref: el => (this.canvasEl = el) })), h("slot", { key: '6b87846ef17b330b0fae5d03103765bad6fdafa6' }))));
34749
34576
  }
34750
34577
  getDocumentApi() {
34751
34578
  if (this.documentApi == null) {
@@ -34753,15 +34580,25 @@ const VertexDocumentViewer = class {
34753
34580
  }
34754
34581
  return this.documentApi;
34755
34582
  }
34583
+ async loadInitialSrc() {
34584
+ await Promise.resolve();
34585
+ await this.handleSrcChange();
34586
+ }
34756
34587
  clearCurrentDocument() {
34757
- var _a, _b, _c, _d, _e, _f;
34588
+ var _a, _b, _c, _d, _e, _f, _g;
34758
34589
  (_a = this.documentRenderer) === null || _a === void 0 ? void 0 : _a.dispose();
34759
34590
  (_b = this.documentApi) === null || _b === void 0 ? void 0 : _b.dispose();
34760
34591
  (_c = this.panInteractionHandler) === null || _c === void 0 ? void 0 : _c.dispose();
34761
34592
  (_d = this.documentApiStateChangedDisposable) === null || _d === void 0 ? void 0 : _d.dispose();
34762
34593
  (_e = this.pageLoadedDisposable) === null || _e === void 0 ? void 0 : _e.dispose();
34763
34594
  (_f = this.pageDrawnDisposable) === null || _f === void 0 ? void 0 : _f.dispose();
34764
- this.layers = undefined;
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();
34765
34602
  }
34766
34603
  handleDocumentApiStateChanged(state) {
34767
34604
  this.documentState = state;
@@ -28,3 +28,4 @@ export declare const GlobalWorkerOptions: {
28
28
  workerSrc: string;
29
29
  };
30
30
  export declare const getDocument: jest.Mock<any, [], any>;
31
+ //# sourceMappingURL=pdfjs-mock.d.ts.map
@@ -1 +1,2 @@
1
1
  import 'abortcontroller-polyfill/dist/polyfill-patch-fetch';
2
+ //# sourceMappingURL=polyfills.d.ts.map
@@ -1 +1,2 @@
1
1
  export declare const triggerResizeObserver: jest.Mock<any, any, any>;
2
+ //# sourceMappingURL=resize-observer.d.ts.map