@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
|
@@ -7,91 +7,6 @@ function getDefaultExportFromCjs (x) {
|
|
|
7
7
|
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
|
|
8
8
|
}
|
|
9
9
|
|
|
10
|
-
/******************************************************************************
|
|
11
|
-
Copyright (c) Microsoft Corporation.
|
|
12
|
-
|
|
13
|
-
Permission to use, copy, modify, and/or distribute this software for any
|
|
14
|
-
purpose with or without fee is hereby granted.
|
|
15
|
-
|
|
16
|
-
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
17
|
-
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
18
|
-
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
19
|
-
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
20
|
-
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
21
|
-
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
22
|
-
PERFORMANCE OF THIS SOFTWARE.
|
|
23
|
-
***************************************************************************** */
|
|
24
|
-
/* global Reflect, Promise, SuppressedError, Symbol, Iterator */
|
|
25
|
-
|
|
26
|
-
var extendStatics = function(d, b) {
|
|
27
|
-
extendStatics = Object.setPrototypeOf ||
|
|
28
|
-
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
29
|
-
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
30
|
-
return extendStatics(d, b);
|
|
31
|
-
};
|
|
32
|
-
|
|
33
|
-
function __extends(d, b) {
|
|
34
|
-
if (typeof b !== "function" && b !== null)
|
|
35
|
-
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
36
|
-
extendStatics(d, b);
|
|
37
|
-
function __() { this.constructor = d; }
|
|
38
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
var __assign = function() {
|
|
42
|
-
__assign = Object.assign || function __assign(t) {
|
|
43
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
44
|
-
s = arguments[i];
|
|
45
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
|
|
46
|
-
}
|
|
47
|
-
return t;
|
|
48
|
-
};
|
|
49
|
-
return __assign.apply(this, arguments);
|
|
50
|
-
};
|
|
51
|
-
|
|
52
|
-
function __awaiter(thisArg, _arguments, P, generator) {
|
|
53
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
54
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
55
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
56
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
57
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
58
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
59
|
-
});
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
function __generator(thisArg, body) {
|
|
63
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
|
64
|
-
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
65
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
66
|
-
function step(op) {
|
|
67
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
68
|
-
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
69
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
70
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
71
|
-
switch (op[0]) {
|
|
72
|
-
case 0: case 1: t = op; break;
|
|
73
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
74
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
75
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
76
|
-
default:
|
|
77
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
78
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
79
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
80
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
81
|
-
if (t[2]) _.ops.pop();
|
|
82
|
-
_.trys.pop(); continue;
|
|
83
|
-
}
|
|
84
|
-
op = body.call(thisArg, _);
|
|
85
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
86
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
|
|
91
|
-
var e = new Error(message);
|
|
92
|
-
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
93
|
-
};
|
|
94
|
-
|
|
95
10
|
/**
|
|
96
11
|
* Clamps the given value between `min` and `max`.
|
|
97
12
|
*
|
|
@@ -121,24 +36,22 @@ function lerp$2(a, b, t) {
|
|
|
121
36
|
/**
|
|
122
37
|
* Returns a new `Point` with the given horizontal and vertical position.
|
|
123
38
|
*/
|
|
124
|
-
function create$d(x, y) {
|
|
125
|
-
|
|
126
|
-
if (y === void 0) { y = 0; }
|
|
127
|
-
return { x: x, y: y };
|
|
39
|
+
function create$d(x = 0, y = 0) {
|
|
40
|
+
return { x, y };
|
|
128
41
|
}
|
|
129
42
|
/**
|
|
130
43
|
* Converts a polar coordinate (length and angle) into a Cartesian coordinate.
|
|
131
44
|
*/
|
|
132
45
|
function polar(length, radians) {
|
|
133
|
-
|
|
134
|
-
|
|
46
|
+
const x = Math.cos(radians) * length;
|
|
47
|
+
const y = Math.sin(radians) * length;
|
|
135
48
|
return create$d(x, y);
|
|
136
49
|
}
|
|
137
50
|
/**
|
|
138
51
|
* Returns the distance between two points.
|
|
139
52
|
*/
|
|
140
53
|
function distance$2(a, b) {
|
|
141
|
-
|
|
54
|
+
const delta = subtract$1(a, b);
|
|
142
55
|
return Math.sqrt(delta.x * delta.x + delta.y * delta.y);
|
|
143
56
|
}
|
|
144
57
|
/**
|
|
@@ -210,7 +123,7 @@ function magnitude$2(pt) {
|
|
|
210
123
|
* Transforms a vector into the corresponding normal (unit) vector.
|
|
211
124
|
*/
|
|
212
125
|
function normalizeVector(pt) {
|
|
213
|
-
|
|
126
|
+
const magnitudeOfPoint = magnitude$2(pt);
|
|
214
127
|
if (magnitudeOfPoint === 0) {
|
|
215
128
|
return create$d(0, 0);
|
|
216
129
|
}
|
|
@@ -228,19 +141,19 @@ function normalDirectionVector(ptA, ptB) {
|
|
|
228
141
|
* Returns a vector orthogonal to the vector between the two given points.
|
|
229
142
|
*/
|
|
230
143
|
function orthogonalVector(ptA, ptB) {
|
|
231
|
-
|
|
144
|
+
const unitVectorBetweenPoints = normalDirectionVector(ptA, ptB);
|
|
232
145
|
// Handle vectors that are parallel to the x or y axis
|
|
233
146
|
if (unitVectorBetweenPoints.x === 0 || unitVectorBetweenPoints.y === 0) {
|
|
234
147
|
return create$d(-1 * unitVectorBetweenPoints.y, unitVectorBetweenPoints.x);
|
|
235
148
|
}
|
|
236
149
|
if (Math.abs(unitVectorBetweenPoints.x) > Math.abs(unitVectorBetweenPoints.y)) {
|
|
237
|
-
|
|
238
|
-
|
|
150
|
+
const vectorXValue = 1 - Math.pow(unitVectorBetweenPoints.x, 2);
|
|
151
|
+
const vectorYValue = -1 * unitVectorBetweenPoints.x * unitVectorBetweenPoints.y;
|
|
239
152
|
return normalizeVector(create$d(vectorXValue, vectorYValue));
|
|
240
153
|
}
|
|
241
154
|
else {
|
|
242
|
-
|
|
243
|
-
|
|
155
|
+
const vectorXValue = -1 * unitVectorBetweenPoints.x * unitVectorBetweenPoints.y;
|
|
156
|
+
const vectorYValue = 1 - Math.pow(unitVectorBetweenPoints.y, 2);
|
|
244
157
|
return normalizeVector(create$d(vectorXValue, vectorYValue));
|
|
245
158
|
}
|
|
246
159
|
}
|
|
@@ -251,13 +164,13 @@ function orthogonalVector(ptA, ptB) {
|
|
|
251
164
|
* @returns A parsed Point.
|
|
252
165
|
*/
|
|
253
166
|
function fromJson$5(json) {
|
|
254
|
-
|
|
167
|
+
const obj = JSON.parse(json);
|
|
255
168
|
if (Array.isArray(obj)) {
|
|
256
|
-
|
|
169
|
+
const [x, y] = obj;
|
|
257
170
|
return create$d(x, y);
|
|
258
171
|
}
|
|
259
172
|
else {
|
|
260
|
-
|
|
173
|
+
const { x, y } = obj;
|
|
261
174
|
return create$d(x, y);
|
|
262
175
|
}
|
|
263
176
|
}
|
|
@@ -285,7 +198,7 @@ var point = /*#__PURE__*/Object.freeze({
|
|
|
285
198
|
* Returns a new `Rectangle` with the given position and size.
|
|
286
199
|
*/
|
|
287
200
|
function create$7(x, y, width, height) {
|
|
288
|
-
return { x
|
|
201
|
+
return { x, y, width, height };
|
|
289
202
|
}
|
|
290
203
|
/**
|
|
291
204
|
* Returns a new `Rectangle` with the given position and size.
|
|
@@ -302,9 +215,9 @@ function fromPointAndDimensions(point, dimensions) {
|
|
|
302
215
|
* @see {@link cropFit}
|
|
303
216
|
*/
|
|
304
217
|
function containFit$1(to, rect) {
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
218
|
+
const scale = Math.min(to.width / rect.width, to.height / rect.height);
|
|
219
|
+
const dimensions$1 = proportionalScale(scale, rect);
|
|
220
|
+
const position = subtract$1(center$2(to), center$1(dimensions$1));
|
|
308
221
|
return fromPointAndDimensions(position, dimensions$1);
|
|
309
222
|
}
|
|
310
223
|
/**
|
|
@@ -316,9 +229,9 @@ function containFit$1(to, rect) {
|
|
|
316
229
|
* @see {@link containFit}
|
|
317
230
|
*/
|
|
318
231
|
function cropFit$1(to, rect) {
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
232
|
+
const scale = Math.max(to.width / rect.width, to.height / rect.height);
|
|
233
|
+
const dimensions$1 = proportionalScale(scale, rect);
|
|
234
|
+
const position = subtract$1(center$2(to), center$1(dimensions$1));
|
|
322
235
|
return fromPointAndDimensions(position, dimensions$1);
|
|
323
236
|
}
|
|
324
237
|
/**
|
|
@@ -330,9 +243,9 @@ function cropFit$1(to, rect) {
|
|
|
330
243
|
* @param rect - the rectangle to scale to fit the specified area
|
|
331
244
|
*/
|
|
332
245
|
function scaleFit$1(to, rect) {
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
246
|
+
const scale = Math.min(Math.sqrt(to / area$1(rect)), 1);
|
|
247
|
+
const dimensions$1 = floor$1(proportionalScale(scale, rect));
|
|
248
|
+
const position = subtract$1(center$2(rect), center$1(dimensions$1));
|
|
336
249
|
return fromPointAndDimensions(position, dimensions$1);
|
|
337
250
|
}
|
|
338
251
|
/**
|
|
@@ -352,27 +265,27 @@ function center$2(rect) {
|
|
|
352
265
|
* Returns a `Dimensions` with the given width and height.
|
|
353
266
|
*
|
|
354
267
|
*/
|
|
355
|
-
|
|
356
|
-
return { width
|
|
268
|
+
const create$6 = (width, height) => {
|
|
269
|
+
return { width, height };
|
|
357
270
|
};
|
|
358
271
|
/**
|
|
359
272
|
* Returns a `Dimensions` with the same width and height.
|
|
360
273
|
*/
|
|
361
|
-
|
|
274
|
+
const square = (size) => {
|
|
362
275
|
return create$6(size, size);
|
|
363
276
|
};
|
|
364
277
|
/**
|
|
365
278
|
* Returns `true` if two dimensions have the same width and height. Otherwise
|
|
366
279
|
* `false`.
|
|
367
280
|
*/
|
|
368
|
-
|
|
281
|
+
const isEqual = (a, b) => {
|
|
369
282
|
return a.width === b.width && a.height === b.height;
|
|
370
283
|
};
|
|
371
284
|
/**
|
|
372
285
|
* Returns a scaled dimensions, where the width is scaled by `scaleX` and height
|
|
373
286
|
* is scaled by `scaleY`.
|
|
374
287
|
*/
|
|
375
|
-
|
|
288
|
+
const scale = (scaleX, scaleY, dimensions) => {
|
|
376
289
|
return {
|
|
377
290
|
width: dimensions.width * scaleX,
|
|
378
291
|
height: dimensions.height * scaleY,
|
|
@@ -381,14 +294,14 @@ var scale = function (scaleX, scaleY, dimensions) {
|
|
|
381
294
|
/**
|
|
382
295
|
* Returns a dimension where each length is scaled by `scaleFactor`.
|
|
383
296
|
*/
|
|
384
|
-
|
|
297
|
+
const proportionalScale = (scaleFactor, dimensions) => {
|
|
385
298
|
return scale(scaleFactor, scaleFactor, dimensions);
|
|
386
299
|
};
|
|
387
300
|
/**
|
|
388
301
|
* Returns a `Dimensions` where the lengths of `dimensions` are trimmed to fit
|
|
389
302
|
* into `to`.
|
|
390
303
|
*/
|
|
391
|
-
|
|
304
|
+
const trim = (to, dimensions) => {
|
|
392
305
|
return {
|
|
393
306
|
width: Math.min(to.width, dimensions.width),
|
|
394
307
|
height: Math.min(to.height, dimensions.height),
|
|
@@ -401,9 +314,9 @@ var trim = function (to, dimensions) {
|
|
|
401
314
|
*
|
|
402
315
|
* @see #cropFit()
|
|
403
316
|
*/
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
return { width
|
|
317
|
+
const containFit = (to, dimensions) => {
|
|
318
|
+
const { width, height } = containFit$1(toRectangle(to), toRectangle(dimensions));
|
|
319
|
+
return { width, height };
|
|
407
320
|
};
|
|
408
321
|
/**
|
|
409
322
|
* Returns a `Dimensions` where the shortest length of `dimensions` will be
|
|
@@ -412,9 +325,9 @@ var containFit = function (to, dimensions) {
|
|
|
412
325
|
*
|
|
413
326
|
* @see #containFit()
|
|
414
327
|
*/
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
return { width
|
|
328
|
+
const cropFit = (to, dimensions) => {
|
|
329
|
+
const { width, height } = cropFit$1(toRectangle(to), toRectangle(dimensions));
|
|
330
|
+
return { width, height };
|
|
418
331
|
};
|
|
419
332
|
/**
|
|
420
333
|
* Returns a `Dimensions` where each side of `dimensions` will be reduced proportionally
|
|
@@ -424,14 +337,14 @@ var cropFit = function (to, dimensions) {
|
|
|
424
337
|
* @param to - the maximum area this dimensions can have
|
|
425
338
|
* @param dimensions - the dimensions to scale to fit the specified area
|
|
426
339
|
*/
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
return { width
|
|
340
|
+
const scaleFit = (to, dimensions) => {
|
|
341
|
+
const { width, height } = scaleFit$1(to, toRectangle(dimensions));
|
|
342
|
+
return { width, height };
|
|
430
343
|
};
|
|
431
344
|
/**
|
|
432
345
|
* Returns a `Dimensions` with each length rounded.
|
|
433
346
|
*/
|
|
434
|
-
|
|
347
|
+
const round = (dimensions) => {
|
|
435
348
|
return {
|
|
436
349
|
width: Math.round(dimensions.width),
|
|
437
350
|
height: Math.round(dimensions.height),
|
|
@@ -440,7 +353,7 @@ var round = function (dimensions) {
|
|
|
440
353
|
/**
|
|
441
354
|
* Returns a `Dimensions` with each length rounded down.
|
|
442
355
|
*/
|
|
443
|
-
|
|
356
|
+
const floor$1 = (dimensions) => {
|
|
444
357
|
return {
|
|
445
358
|
width: Math.floor(dimensions.width),
|
|
446
359
|
height: Math.floor(dimensions.height),
|
|
@@ -449,22 +362,20 @@ var floor$1 = function (dimensions) {
|
|
|
449
362
|
/**
|
|
450
363
|
* Returns the center point of the given `dimensions`.
|
|
451
364
|
*/
|
|
452
|
-
|
|
365
|
+
const center$1 = (dimensions) => {
|
|
453
366
|
return { x: dimensions.width / 2, y: dimensions.height / 2 };
|
|
454
367
|
};
|
|
455
368
|
/**
|
|
456
369
|
* Returns the aspect ratio of the given `dimensions`, as defined by width over
|
|
457
370
|
* height.
|
|
458
371
|
*/
|
|
459
|
-
|
|
460
|
-
var width = _a.width, height = _a.height;
|
|
372
|
+
const aspectRatio = ({ width, height }) => {
|
|
461
373
|
return width / height;
|
|
462
374
|
};
|
|
463
375
|
/**
|
|
464
376
|
* Returns the area of the given `dimensions`.
|
|
465
377
|
*/
|
|
466
|
-
|
|
467
|
-
var width = _a.width, height = _a.height;
|
|
378
|
+
const area = ({ width, height }) => {
|
|
468
379
|
return width * height;
|
|
469
380
|
};
|
|
470
381
|
/**
|
|
@@ -473,7 +384,7 @@ var area = function (_a) {
|
|
|
473
384
|
* @param ratio - Aspect ratio to fit the provided Dimensions to
|
|
474
385
|
* @param dimensions - Dimensions to fit to the specified ratio
|
|
475
386
|
*/
|
|
476
|
-
|
|
387
|
+
const fitToRatio = (ratio, dimensions) => {
|
|
477
388
|
if (dimensions.width >= dimensions.height * ratio) {
|
|
478
389
|
return create$6(dimensions.height * ratio, dimensions.height);
|
|
479
390
|
}
|
|
@@ -482,8 +393,7 @@ var fitToRatio = function (ratio, dimensions) {
|
|
|
482
393
|
/**
|
|
483
394
|
* Converts a dimension to a rectangle, with an optional position.
|
|
484
395
|
*/
|
|
485
|
-
function toRectangle(dimensions, position) {
|
|
486
|
-
if (position === void 0) { position = create$d(); }
|
|
396
|
+
function toRectangle(dimensions, position = create$d()) {
|
|
487
397
|
return fromPointAndDimensions(position, dimensions);
|
|
488
398
|
}
|
|
489
399
|
|
|
@@ -34196,153 +34106,56 @@ globalThis.pdfjsLib = {
|
|
|
34196
34106
|
XfaLayer: XfaLayer
|
|
34197
34107
|
};
|
|
34198
34108
|
|
|
34199
|
-
|
|
34200
|
-
|
|
34201
|
-
* module is useful for parsing to or from JSON/protobufs to domain types.
|
|
34202
|
-
*
|
|
34203
|
-
* Mappers support greedy validation, so all validation errors are aggregated
|
|
34204
|
-
* and reported vs failing on the first invalid input.
|
|
34205
|
-
*
|
|
34206
|
-
* @example
|
|
34207
|
-
*
|
|
34208
|
-
* ```ts
|
|
34209
|
-
* import { Mapper as M } from '@vertexvis/utils';
|
|
34210
|
-
*
|
|
34211
|
-
* interface Address {
|
|
34212
|
-
* address: string;
|
|
34213
|
-
* city: string;
|
|
34214
|
-
* state: string;
|
|
34215
|
-
* zip: string;
|
|
34216
|
-
* }
|
|
34217
|
-
*
|
|
34218
|
-
* interface Person {
|
|
34219
|
-
* name: string;
|
|
34220
|
-
* addresses: Address[];
|
|
34221
|
-
* }
|
|
34222
|
-
*
|
|
34223
|
-
* type AddressJson = Partial<Address>;
|
|
34224
|
-
* type PersonJson = {
|
|
34225
|
-
* name?: string;
|
|
34226
|
-
* addresses?: AddressJson[];
|
|
34227
|
-
* }
|
|
34228
|
-
*
|
|
34229
|
-
* const mapAddress: M.Func<AddressJson, Address> = M.defineMapper(
|
|
34230
|
-
* M.read(
|
|
34231
|
-
* M.requireProp('address'),
|
|
34232
|
-
* M.requireProp('city'),
|
|
34233
|
-
* M.requireProp('state'),
|
|
34234
|
-
* M.requireProp('zip')
|
|
34235
|
-
* ),
|
|
34236
|
-
* ([address, city, state, zip]) => ({
|
|
34237
|
-
* address, city, state, zip
|
|
34238
|
-
* })
|
|
34239
|
-
* );
|
|
34240
|
-
*
|
|
34241
|
-
* const mapPerson: M.Func<PersonJson, Person> = M.defineMapper(
|
|
34242
|
-
* M.read(
|
|
34243
|
-
* M.requireProp('name'),
|
|
34244
|
-
* M.mapProp(
|
|
34245
|
-
* 'addresses',
|
|
34246
|
-
* M.compose(M.required('addresses'), M.mapArray(mapAddress))
|
|
34247
|
-
* )
|
|
34248
|
-
* ),
|
|
34249
|
-
* ([name, addresses]) => ({ name, addresses })
|
|
34250
|
-
* );
|
|
34251
|
-
*
|
|
34252
|
-
* const person = mapPerson({
|
|
34253
|
-
* name: 'John',
|
|
34254
|
-
* addresses: [{ address: '123', city: 'Ames', state: 'IA', zip: '50010' }]
|
|
34255
|
-
* });
|
|
34256
|
-
*
|
|
34257
|
-
* const invalidPerson = mapPerson({
|
|
34258
|
-
* addresses: [{ city: 'Ames', state: 'IA', zip: '50010' }]
|
|
34259
|
-
* });
|
|
34260
|
-
* ```
|
|
34261
|
-
* // {
|
|
34262
|
-
* // errors: ["Name is required.", "Address is required."]
|
|
34263
|
-
* // }
|
|
34264
|
-
*
|
|
34265
|
-
* @module
|
|
34266
|
-
*/
|
|
34267
|
-
/**
|
|
34268
|
-
* An error that is thrown when validation of a schema fails.
|
|
34269
|
-
*
|
|
34270
|
-
* @see {@link ifInvalidThrow} - for throwing errors on invalid input.
|
|
34271
|
-
*/
|
|
34272
|
-
/** @class */ ((function (_super) {
|
|
34273
|
-
__extends(MapperValidationError, _super);
|
|
34274
|
-
function MapperValidationError(errors) {
|
|
34275
|
-
var _this = _super.call(this, 'Validation error mapping object.') || this;
|
|
34276
|
-
_this.errors = errors;
|
|
34277
|
-
Object.setPrototypeOf(_this, MapperValidationError.prototype);
|
|
34278
|
-
return _this;
|
|
34279
|
-
}
|
|
34280
|
-
return MapperValidationError;
|
|
34281
|
-
})(Error));
|
|
34282
|
-
|
|
34283
|
-
var EventDispatcher = /** @class */ (function () {
|
|
34284
|
-
function EventDispatcher() {
|
|
34109
|
+
class EventDispatcher {
|
|
34110
|
+
constructor() {
|
|
34285
34111
|
this.listeners = [];
|
|
34286
34112
|
}
|
|
34287
|
-
|
|
34288
|
-
var _this = this;
|
|
34113
|
+
on(listener, opts = {}) {
|
|
34289
34114
|
var _a;
|
|
34290
|
-
if (opts === void 0) { opts = {}; }
|
|
34291
34115
|
this.listeners.push(listener);
|
|
34292
|
-
|
|
34293
|
-
controller.signal.addEventListener('abort',
|
|
34294
|
-
(_a = opts.abort) === null || _a === void 0 ? void 0 : _a.addEventListener('abort',
|
|
34295
|
-
return { dispose:
|
|
34296
|
-
}
|
|
34297
|
-
|
|
34298
|
-
|
|
34299
|
-
|
|
34300
|
-
return new Promise(function (resolve) {
|
|
34301
|
-
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) => {
|
|
34302
34124
|
subscription.dispose();
|
|
34303
34125
|
resolve(event);
|
|
34304
34126
|
}, opts);
|
|
34305
34127
|
});
|
|
34306
|
-
}
|
|
34307
|
-
|
|
34308
|
-
|
|
34309
|
-
|
|
34310
|
-
|
|
34311
|
-
|
|
34312
|
-
|
|
34313
|
-
|
|
34314
|
-
|
|
34315
|
-
|
|
34316
|
-
|
|
34317
|
-
|
|
34318
|
-
if (predicate(event)) {
|
|
34319
|
-
controller.abort();
|
|
34320
|
-
resolve(event);
|
|
34321
|
-
}
|
|
34322
|
-
}, __assign(__assign({}, opts), { abort: controller.signal }));
|
|
34323
|
-
})];
|
|
34324
|
-
});
|
|
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 });
|
|
34325
34140
|
});
|
|
34326
|
-
}
|
|
34327
|
-
|
|
34328
|
-
|
|
34329
|
-
return this.on(function (event) {
|
|
34141
|
+
}
|
|
34142
|
+
when(predicate, listener, opts = {}) {
|
|
34143
|
+
return this.on((event) => {
|
|
34330
34144
|
if (predicate(event)) {
|
|
34331
34145
|
listener(event);
|
|
34332
34146
|
}
|
|
34333
34147
|
}, opts);
|
|
34334
|
-
}
|
|
34335
|
-
|
|
34336
|
-
|
|
34148
|
+
}
|
|
34149
|
+
off(listener) {
|
|
34150
|
+
const index = this.listeners.indexOf(listener);
|
|
34337
34151
|
if (index !== -1) {
|
|
34338
34152
|
this.listeners.splice(index, 1);
|
|
34339
34153
|
}
|
|
34340
|
-
}
|
|
34341
|
-
|
|
34342
|
-
this.listeners.forEach(
|
|
34343
|
-
}
|
|
34344
|
-
|
|
34345
|
-
}());
|
|
34154
|
+
}
|
|
34155
|
+
emit(event) {
|
|
34156
|
+
this.listeners.forEach((listener) => listener(event));
|
|
34157
|
+
}
|
|
34158
|
+
}
|
|
34346
34159
|
|
|
34347
34160
|
const MAX_ZOOM_PERCENTAGE = 600;
|
|
34348
34161
|
const MIN_ZOOM_PERCENTAGE = 10;
|
package/dist/types/index.d.ts
CHANGED
|
@@ -13,3 +13,4 @@ export type LayerSupportedApi = DocumentApi & LayerSupport;
|
|
|
13
13
|
* Returns a boolean indicating whether the provided document API supports layers.
|
|
14
14
|
*/
|
|
15
15
|
export declare function apiSupportsLayers(api: DocumentApi): api is LayerSupportedApi;
|
|
16
|
+
//# sourceMappingURL=types.d.ts.map
|
package/dist/types/lib/dom.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
export declare function getElementBoundingClientRect(element: HTMLElement): ClientRect;
|
|
2
2
|
export declare function createElement<T extends HTMLElement>(tagName: string): T;
|
|
3
3
|
export declare function getAllVertexElementChildren(element: Element): Element[];
|
|
4
|
+
//# sourceMappingURL=dom.d.ts.map
|