@vertexvis/doc-viewer 1.0.2-testing.4 → 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.
- package/dist/cjs/vertex-document-viewer.cjs.entry.js +81 -268
- 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 +81 -268
- package/dist/types/__mocks__/pdfjs-mock.d.ts +1 -0
- 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 +1 -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 +1 -0
- 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 +1 -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-d55c9d5e.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
|
|
|
@@ -34217,153 +34127,56 @@ globalThis.pdfjsLib = {
|
|
|
34217
34127
|
XfaLayer: XfaLayer
|
|
34218
34128
|
};
|
|
34219
34129
|
|
|
34220
|
-
|
|
34221
|
-
|
|
34222
|
-
* module is useful for parsing to or from JSON/protobufs to domain types.
|
|
34223
|
-
*
|
|
34224
|
-
* Mappers support greedy validation, so all validation errors are aggregated
|
|
34225
|
-
* and reported vs failing on the first invalid input.
|
|
34226
|
-
*
|
|
34227
|
-
* @example
|
|
34228
|
-
*
|
|
34229
|
-
* ```ts
|
|
34230
|
-
* import { Mapper as M } from '@vertexvis/utils';
|
|
34231
|
-
*
|
|
34232
|
-
* interface Address {
|
|
34233
|
-
* address: string;
|
|
34234
|
-
* city: string;
|
|
34235
|
-
* state: string;
|
|
34236
|
-
* zip: string;
|
|
34237
|
-
* }
|
|
34238
|
-
*
|
|
34239
|
-
* interface Person {
|
|
34240
|
-
* name: string;
|
|
34241
|
-
* addresses: Address[];
|
|
34242
|
-
* }
|
|
34243
|
-
*
|
|
34244
|
-
* type AddressJson = Partial<Address>;
|
|
34245
|
-
* type PersonJson = {
|
|
34246
|
-
* name?: string;
|
|
34247
|
-
* addresses?: AddressJson[];
|
|
34248
|
-
* }
|
|
34249
|
-
*
|
|
34250
|
-
* const mapAddress: M.Func<AddressJson, Address> = M.defineMapper(
|
|
34251
|
-
* M.read(
|
|
34252
|
-
* M.requireProp('address'),
|
|
34253
|
-
* M.requireProp('city'),
|
|
34254
|
-
* M.requireProp('state'),
|
|
34255
|
-
* M.requireProp('zip')
|
|
34256
|
-
* ),
|
|
34257
|
-
* ([address, city, state, zip]) => ({
|
|
34258
|
-
* address, city, state, zip
|
|
34259
|
-
* })
|
|
34260
|
-
* );
|
|
34261
|
-
*
|
|
34262
|
-
* const mapPerson: M.Func<PersonJson, Person> = M.defineMapper(
|
|
34263
|
-
* M.read(
|
|
34264
|
-
* M.requireProp('name'),
|
|
34265
|
-
* M.mapProp(
|
|
34266
|
-
* 'addresses',
|
|
34267
|
-
* M.compose(M.required('addresses'), M.mapArray(mapAddress))
|
|
34268
|
-
* )
|
|
34269
|
-
* ),
|
|
34270
|
-
* ([name, addresses]) => ({ name, addresses })
|
|
34271
|
-
* );
|
|
34272
|
-
*
|
|
34273
|
-
* const person = mapPerson({
|
|
34274
|
-
* name: 'John',
|
|
34275
|
-
* addresses: [{ address: '123', city: 'Ames', state: 'IA', zip: '50010' }]
|
|
34276
|
-
* });
|
|
34277
|
-
*
|
|
34278
|
-
* const invalidPerson = mapPerson({
|
|
34279
|
-
* addresses: [{ city: 'Ames', state: 'IA', zip: '50010' }]
|
|
34280
|
-
* });
|
|
34281
|
-
* ```
|
|
34282
|
-
* // {
|
|
34283
|
-
* // errors: ["Name is required.", "Address is required."]
|
|
34284
|
-
* // }
|
|
34285
|
-
*
|
|
34286
|
-
* @module
|
|
34287
|
-
*/
|
|
34288
|
-
/**
|
|
34289
|
-
* An error that is thrown when validation of a schema fails.
|
|
34290
|
-
*
|
|
34291
|
-
* @see {@link ifInvalidThrow} - for throwing errors on invalid input.
|
|
34292
|
-
*/
|
|
34293
|
-
/** @class */ ((function (_super) {
|
|
34294
|
-
__extends(MapperValidationError, _super);
|
|
34295
|
-
function MapperValidationError(errors) {
|
|
34296
|
-
var _this = _super.call(this, 'Validation error mapping object.') || this;
|
|
34297
|
-
_this.errors = errors;
|
|
34298
|
-
Object.setPrototypeOf(_this, MapperValidationError.prototype);
|
|
34299
|
-
return _this;
|
|
34300
|
-
}
|
|
34301
|
-
return MapperValidationError;
|
|
34302
|
-
})(Error));
|
|
34303
|
-
|
|
34304
|
-
var EventDispatcher = /** @class */ (function () {
|
|
34305
|
-
function EventDispatcher() {
|
|
34130
|
+
class EventDispatcher {
|
|
34131
|
+
constructor() {
|
|
34306
34132
|
this.listeners = [];
|
|
34307
34133
|
}
|
|
34308
|
-
|
|
34309
|
-
var _this = this;
|
|
34134
|
+
on(listener, opts = {}) {
|
|
34310
34135
|
var _a;
|
|
34311
|
-
if (opts === void 0) { opts = {}; }
|
|
34312
34136
|
this.listeners.push(listener);
|
|
34313
|
-
|
|
34314
|
-
controller.signal.addEventListener('abort',
|
|
34315
|
-
(_a = opts.abort) === null || _a === void 0 ? void 0 : _a.addEventListener('abort',
|
|
34316
|
-
return { dispose:
|
|
34317
|
-
}
|
|
34318
|
-
|
|
34319
|
-
|
|
34320
|
-
|
|
34321
|
-
return new Promise(function (resolve) {
|
|
34322
|
-
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) => {
|
|
34323
34145
|
subscription.dispose();
|
|
34324
34146
|
resolve(event);
|
|
34325
34147
|
}, opts);
|
|
34326
34148
|
});
|
|
34327
|
-
}
|
|
34328
|
-
|
|
34329
|
-
|
|
34330
|
-
|
|
34331
|
-
|
|
34332
|
-
|
|
34333
|
-
|
|
34334
|
-
|
|
34335
|
-
|
|
34336
|
-
|
|
34337
|
-
|
|
34338
|
-
|
|
34339
|
-
if (predicate(event)) {
|
|
34340
|
-
controller.abort();
|
|
34341
|
-
resolve(event);
|
|
34342
|
-
}
|
|
34343
|
-
}, __assign(__assign({}, opts), { abort: controller.signal }));
|
|
34344
|
-
})];
|
|
34345
|
-
});
|
|
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 });
|
|
34346
34161
|
});
|
|
34347
|
-
}
|
|
34348
|
-
|
|
34349
|
-
|
|
34350
|
-
return this.on(function (event) {
|
|
34162
|
+
}
|
|
34163
|
+
when(predicate, listener, opts = {}) {
|
|
34164
|
+
return this.on((event) => {
|
|
34351
34165
|
if (predicate(event)) {
|
|
34352
34166
|
listener(event);
|
|
34353
34167
|
}
|
|
34354
34168
|
}, opts);
|
|
34355
|
-
}
|
|
34356
|
-
|
|
34357
|
-
|
|
34169
|
+
}
|
|
34170
|
+
off(listener) {
|
|
34171
|
+
const index = this.listeners.indexOf(listener);
|
|
34358
34172
|
if (index !== -1) {
|
|
34359
34173
|
this.listeners.splice(index, 1);
|
|
34360
34174
|
}
|
|
34361
|
-
}
|
|
34362
|
-
|
|
34363
|
-
this.listeners.forEach(
|
|
34364
|
-
}
|
|
34365
|
-
|
|
34366
|
-
}());
|
|
34175
|
+
}
|
|
34176
|
+
emit(event) {
|
|
34177
|
+
this.listeners.forEach((listener) => listener(event));
|
|
34178
|
+
}
|
|
34179
|
+
}
|
|
34367
34180
|
|
|
34368
34181
|
const MAX_ZOOM_PERCENTAGE = 600;
|
|
34369
34182
|
const MIN_ZOOM_PERCENTAGE = 10;
|