@applitools/eyes-testcafe 2.0.0-beta.9 → 2.0.0

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 (75) hide show
  1. package/CHANGELOG.md +467 -0
  2. package/LICENSE +1 -1
  3. package/README.md +7 -531
  4. package/dist/api.js +51 -0
  5. package/dist/extract-environment.js +15 -0
  6. package/dist/index-legacy.js +5 -0
  7. package/dist/index.js +19 -0
  8. package/dist/legacy.js +225 -0
  9. package/dist/spec-driver.js +245 -0
  10. package/package.json +73 -77
  11. package/types/index-legacy.d.ts +2 -0
  12. package/types/index.d.ts +1833 -0
  13. package/dist/captureFrameAndPoll.js +0 -1468
  14. package/dist/captureFrameAndPollForIE.js +0 -12569
  15. package/index.js +0 -30
  16. package/lib/BordersAwareElementContentLocationProvider.js +0 -79
  17. package/lib/Eyes.js +0 -927
  18. package/lib/EyesFactory.js +0 -73
  19. package/lib/EyesTestCafe.js +0 -1277
  20. package/lib/EyesTestcafeUtils.js +0 -440
  21. package/lib/EyesVisualGrid.js +0 -345
  22. package/lib/ImageOrientationHandler.js +0 -31
  23. package/lib/JavascriptHandler.js +0 -20
  24. package/lib/TestCafeExecutor.js +0 -57
  25. package/lib/capture/EyesWebDriverScreenshot.js +0 -650
  26. package/lib/capture/EyesWebDriverScreenshotFactory.js +0 -32
  27. package/lib/capture/FirefoxScreenshotImageProvider.js +0 -63
  28. package/lib/capture/ImageProviderFactory.js +0 -38
  29. package/lib/capture/SafariScreenshotImageProvider.js +0 -254
  30. package/lib/capture/TakesScreenshotImageProvider.js +0 -35
  31. package/lib/errors/EyesDriverOperationError.js +0 -10
  32. package/lib/errors/NoFramesError.js +0 -7
  33. package/lib/fluent/AccessibilityRegionByElement.js +0 -46
  34. package/lib/fluent/AccessibilityRegionBySelector.js +0 -58
  35. package/lib/fluent/FloatingRegionByElement.js +0 -56
  36. package/lib/fluent/FloatingRegionBySelector.js +0 -63
  37. package/lib/fluent/FrameLocator.js +0 -110
  38. package/lib/fluent/IgnoreRegionByElement.js +0 -51
  39. package/lib/fluent/IgnoreRegionBySelector.js +0 -57
  40. package/lib/fluent/SelectorByElement.js +0 -37
  41. package/lib/fluent/SelectorByLocator.js +0 -47
  42. package/lib/fluent/Target.js +0 -17
  43. package/lib/fluent/TestcafeCheckSettings.js +0 -352
  44. package/lib/frames/Frame.js +0 -149
  45. package/lib/frames/FrameChain.js +0 -175
  46. package/lib/getCaptureDomScript.js +0 -14
  47. package/lib/hash.js +0 -15
  48. package/lib/isTestcafeSelector.js +0 -7
  49. package/lib/makeClientFunctionWrapper.js +0 -61
  50. package/lib/positioning/CssTranslatePositionMemento.js +0 -39
  51. package/lib/positioning/CssTranslatePositionProvider.js +0 -130
  52. package/lib/positioning/ElementPositionMemento.js +0 -36
  53. package/lib/positioning/ElementPositionProvider.js +0 -88
  54. package/lib/positioning/FirefoxRegionPositionCompensation.js +0 -45
  55. package/lib/positioning/ImageRotation.js +0 -22
  56. package/lib/positioning/OverflowAwareCssTranslatePositionProvider.js +0 -17
  57. package/lib/positioning/OverflowAwareScrollPositionProvider.js +0 -17
  58. package/lib/positioning/RegionPositionCompensationFactory.js +0 -37
  59. package/lib/positioning/SafariRegionPositionCompensation.js +0 -26
  60. package/lib/positioning/ScrollPositionMemento.js +0 -36
  61. package/lib/positioning/ScrollPositionProvider.js +0 -118
  62. package/lib/positioning/fixImageMarkPosition.js +0 -36
  63. package/lib/regionVisibility/MoveToRegionVisibilityStrategy.js +0 -55
  64. package/lib/regionVisibility/NopRegionVisibilityStrategy.js +0 -35
  65. package/lib/regionVisibility/RegionVisibilityStrategy.js +0 -30
  66. package/lib/runner/ClassicRunner.js +0 -49
  67. package/lib/runner/EyesRunner.js +0 -41
  68. package/lib/runner/TestResultContainer.js +0 -38
  69. package/lib/runner/TestResultsSummary.js +0 -112
  70. package/lib/runner/VisualGridRunner.js +0 -57
  71. package/lib/safeExecuteFunction.js +0 -28
  72. package/lib/wrappers/EyesTargetLocator.js +0 -335
  73. package/lib/wrappers/EyesWebDriver.js +0 -571
  74. package/lib/wrappers/EyesWebElement.js +0 -383
  75. package/lib/wrappers/EyesWebElementPromise.js +0 -68
@@ -1,1468 +0,0 @@
1
-
2
- module.exports = () => {
3
- var captureFrameAndPoll = (function () {
4
- 'use strict';
5
-
6
- function createCommonjsModule(fn, module) {
7
- return module = { exports: {} }, fn(module, module.exports), module.exports;
8
- }
9
-
10
- var runtime_1 = createCommonjsModule(function (module) {
11
- /**
12
- * Copyright (c) 2014-present, Facebook, Inc.
13
- *
14
- * This source code is licensed under the MIT license found in the
15
- * LICENSE file in the root directory of this source tree.
16
- */
17
- var runtime = function (exports) {
18
-
19
- var Op = window.Object.prototype;
20
- var hasOwn = Op.hasOwnProperty;
21
- var undefined$1; // More compressible than void 0.
22
-
23
- var $Symbol = typeof window.Symbol === "function" ? window.Symbol : {};
24
- var iteratorSymbol = $Symbol.iterator || "@@iterator";
25
- var asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator";
26
- var toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag";
27
-
28
- function wrap(innerFn, outerFn, self, tryLocsList) {
29
- // If outerFn provided and outerFn.prototype is a Generator, then outerFn.prototype instanceof Generator.
30
- var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator;
31
- var generator = window.Object.create(protoGenerator.prototype);
32
- var context = new Context(tryLocsList || []); // The ._invoke method unifies the implementations of the .next,
33
- // .throw, and .return methods.
34
-
35
- generator._invoke = makeInvokeMethod(innerFn, self, context);
36
- return generator;
37
- }
38
-
39
- exports.wrap = wrap; // Try/catch helper to minimize deoptimizations. Returns a completion
40
- // record like context.tryEntries[i].completion. This interface could
41
- // have been (and was previously) designed to take a closure to be
42
- // invoked without arguments, but in all the cases we care about we
43
- // already have an existing method we want to call, so there's no need
44
- // to create a new function object. We can even get away with assuming
45
- // the method takes exactly one argument, since that happens to be true
46
- // in every case, so we don't have to touch the arguments object. The
47
- // only additional allocation required is the completion record, which
48
- // has a stable shape and so hopefully should be cheap to allocate.
49
-
50
- function tryCatch(fn, obj, arg) {
51
- try {
52
- return {
53
- type: "normal",
54
- arg: fn.call(obj, arg)
55
- };
56
- } catch (err) {
57
- return {
58
- type: "throw",
59
- arg: err
60
- };
61
- }
62
- }
63
-
64
- var GenStateSuspendedStart = "suspendedStart";
65
- var GenStateSuspendedYield = "suspendedYield";
66
- var GenStateExecuting = "executing";
67
- var GenStateCompleted = "completed"; // Returning this object from the innerFn has the same effect as
68
- // breaking out of the dispatch switch statement.
69
-
70
- var ContinueSentinel = {}; // Dummy constructor functions that we use as the .constructor and
71
- // .constructor.prototype properties for functions that return Generator
72
- // objects. For full spec compliance, you may wish to configure your
73
- // minifier not to mangle the names of these two functions.
74
-
75
- function Generator() {}
76
-
77
- function GeneratorFunction() {}
78
-
79
- function GeneratorFunctionPrototype() {} // This is a polyfill for %IteratorPrototype% for environments that
80
- // don't natively support it.
81
-
82
-
83
- var IteratorPrototype = {};
84
-
85
- IteratorPrototype[iteratorSymbol] = function () {
86
- return this;
87
- };
88
-
89
- var getProto = window.Object.getPrototypeOf;
90
- var NativeIteratorPrototype = getProto && getProto(getProto(values([])));
91
-
92
- if (NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol)) {
93
- // This environment has a native %IteratorPrototype%; use it instead
94
- // of the polyfill.
95
- IteratorPrototype = NativeIteratorPrototype;
96
- }
97
-
98
- var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = window.Object.create(IteratorPrototype);
99
- GeneratorFunction.prototype = Gp.constructor = GeneratorFunctionPrototype;
100
- GeneratorFunctionPrototype.constructor = GeneratorFunction;
101
- GeneratorFunctionPrototype[toStringTagSymbol] = GeneratorFunction.displayName = "GeneratorFunction"; // Helper for defining the .next, .throw, and .return methods of the
102
- // Iterator interface in terms of a single ._invoke method.
103
-
104
- function defineIteratorMethods(prototype) {
105
- ["next", "throw", "return"].forEach(function (method) {
106
- prototype[method] = function (arg) {
107
- return this._invoke(method, arg);
108
- };
109
- });
110
- }
111
-
112
- exports.isGeneratorFunction = function (genFun) {
113
- var ctor = typeof genFun === "function" && genFun.constructor;
114
- return ctor ? ctor === GeneratorFunction || // For the native GeneratorFunction constructor, the best we can
115
- // do is to check its .name property.
116
- (ctor.displayName || ctor.name) === "GeneratorFunction" : false;
117
- };
118
-
119
- exports.mark = function (genFun) {
120
- if (window.Object.setPrototypeOf) {
121
- window.Object.setPrototypeOf(genFun, GeneratorFunctionPrototype);
122
- } else {
123
- genFun.__proto__ = GeneratorFunctionPrototype;
124
-
125
- if (!(toStringTagSymbol in genFun)) {
126
- genFun[toStringTagSymbol] = "GeneratorFunction";
127
- }
128
- }
129
-
130
- genFun.prototype = window.Object.create(Gp);
131
- return genFun;
132
- }; // Within the body of any async function, `await x` is transformed to
133
- // `yield regeneratorRuntime.awrap(x)`, so that the runtime can test
134
- // `hasOwn.call(value, "__await")` to determine if the yielded value is
135
- // meant to be awaited.
136
-
137
-
138
- exports.awrap = function (arg) {
139
- return {
140
- __await: arg
141
- };
142
- };
143
-
144
- function AsyncIterator(generator) {
145
- function invoke(method, arg, resolve, reject) {
146
- var record = tryCatch(generator[method], generator, arg);
147
-
148
- if (record.type === "throw") {
149
- reject(record.arg);
150
- } else {
151
- var result = record.arg;
152
- var value = result.value;
153
-
154
- if (value && typeof value === "object" && hasOwn.call(value, "__await")) {
155
- return Promise.resolve(value.__await).then(function (value) {
156
- invoke("next", value, resolve, reject);
157
- }, function (err) {
158
- invoke("throw", err, resolve, reject);
159
- });
160
- }
161
-
162
- return Promise.resolve(value).then(function (unwrapped) {
163
- // When a yielded Promise is resolved, its final value becomes
164
- // the .value of the Promise<{value,done}> result for the
165
- // current iteration.
166
- result.value = unwrapped;
167
- resolve(result);
168
- }, function (error) {
169
- // If a rejected Promise was yielded, throw the rejection back
170
- // into the async generator function so it can be handled there.
171
- return invoke("throw", error, resolve, reject);
172
- });
173
- }
174
- }
175
-
176
- var previousPromise;
177
-
178
- function enqueue(method, arg) {
179
- function callInvokeWithMethodAndArg() {
180
- return new Promise(function (resolve, reject) {
181
- invoke(method, arg, resolve, reject);
182
- });
183
- }
184
-
185
- return previousPromise = // If enqueue has been called before, then we want to wait until
186
- // all previous Promises have been resolved before calling invoke,
187
- // so that results are always delivered in the correct order. If
188
- // enqueue has not been called before, then it is important to
189
- // call invoke immediately, without waiting on a callback to fire,
190
- // so that the async generator function has the opportunity to do
191
- // any necessary setup in a predictable way. This predictability
192
- // is why the Promise constructor synchronously invokes its
193
- // executor callback, and why async functions synchronously
194
- // execute code before the first await. Since we implement simple
195
- // async functions in terms of async generators, it is especially
196
- // important to get this right, even though it requires care.
197
- previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, // Avoid propagating failures to Promises returned by later
198
- // invocations of the iterator.
199
- callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg();
200
- } // Define the unified helper method that is used to implement .next,
201
- // .throw, and .return (see defineIteratorMethods).
202
-
203
-
204
- this._invoke = enqueue;
205
- }
206
-
207
- defineIteratorMethods(AsyncIterator.prototype);
208
-
209
- AsyncIterator.prototype[asyncIteratorSymbol] = function () {
210
- return this;
211
- };
212
-
213
- exports.AsyncIterator = AsyncIterator; // Note that simple async functions are implemented on top of
214
- // AsyncIterator objects; they just return a Promise for the value of
215
- // the final result produced by the iterator.
216
-
217
- exports.async = function (innerFn, outerFn, self, tryLocsList) {
218
- var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList));
219
- return exports.isGeneratorFunction(outerFn) ? iter // If outerFn is a generator, return the full iterator.
220
- : iter.next().then(function (result) {
221
- return result.done ? result.value : iter.next();
222
- });
223
- };
224
-
225
- function makeInvokeMethod(innerFn, self, context) {
226
- var state = GenStateSuspendedStart;
227
- return function invoke(method, arg) {
228
- if (state === GenStateExecuting) {
229
- throw new Error("Generator is already running");
230
- }
231
-
232
- if (state === GenStateCompleted) {
233
- if (method === "throw") {
234
- throw arg;
235
- } // Be forgiving, per 25.3.3.3.3 of the spec:
236
- // https://people.mozilla.org/~jorendorff/es6-draft.html#sec-generatorresume
237
-
238
-
239
- return doneResult();
240
- }
241
-
242
- context.method = method;
243
- context.arg = arg;
244
-
245
- while (true) {
246
- var delegate = context.delegate;
247
-
248
- if (delegate) {
249
- var delegateResult = maybeInvokeDelegate(delegate, context);
250
-
251
- if (delegateResult) {
252
- if (delegateResult === ContinueSentinel) continue;
253
- return delegateResult;
254
- }
255
- }
256
-
257
- if (context.method === "next") {
258
- // Setting context._sent for legacy support of Babel's
259
- // function.sent implementation.
260
- context.sent = context._sent = context.arg;
261
- } else if (context.method === "throw") {
262
- if (state === GenStateSuspendedStart) {
263
- state = GenStateCompleted;
264
- throw context.arg;
265
- }
266
-
267
- context.dispatchException(context.arg);
268
- } else if (context.method === "return") {
269
- context.abrupt("return", context.arg);
270
- }
271
-
272
- state = GenStateExecuting;
273
- var record = tryCatch(innerFn, self, context);
274
-
275
- if (record.type === "normal") {
276
- // If an exception is thrown from innerFn, we leave state ===
277
- // GenStateExecuting and loop back for another invocation.
278
- state = context.done ? GenStateCompleted : GenStateSuspendedYield;
279
-
280
- if (record.arg === ContinueSentinel) {
281
- continue;
282
- }
283
-
284
- return {
285
- value: record.arg,
286
- done: context.done
287
- };
288
- } else if (record.type === "throw") {
289
- state = GenStateCompleted; // Dispatch the exception by looping back around to the
290
- // context.dispatchException(context.arg) call above.
291
-
292
- context.method = "throw";
293
- context.arg = record.arg;
294
- }
295
- }
296
- };
297
- } // Call delegate.iterator[context.method](context.arg) and handle the
298
- // result, either by returning a { value, done } result from the
299
- // delegate iterator, or by modifying context.method and context.arg,
300
- // setting context.delegate to null, and returning the ContinueSentinel.
301
-
302
-
303
- function maybeInvokeDelegate(delegate, context) {
304
- var method = delegate.iterator[context.method];
305
-
306
- if (method === undefined$1) {
307
- // A .throw or .return when the delegate iterator has no .throw
308
- // method always terminates the yield* loop.
309
- context.delegate = null;
310
-
311
- if (context.method === "throw") {
312
- // Note: ["return"] must be used for ES3 parsing compatibility.
313
- if (delegate.iterator["return"]) {
314
- // If the delegate iterator has a return method, give it a
315
- // chance to clean up.
316
- context.method = "return";
317
- context.arg = undefined$1;
318
- maybeInvokeDelegate(delegate, context);
319
-
320
- if (context.method === "throw") {
321
- // If maybeInvokeDelegate(context) changed context.method from
322
- // "return" to "throw", let that override the TypeError below.
323
- return ContinueSentinel;
324
- }
325
- }
326
-
327
- context.method = "throw";
328
- context.arg = new TypeError("The iterator does not provide a 'throw' method");
329
- }
330
-
331
- return ContinueSentinel;
332
- }
333
-
334
- var record = tryCatch(method, delegate.iterator, context.arg);
335
-
336
- if (record.type === "throw") {
337
- context.method = "throw";
338
- context.arg = record.arg;
339
- context.delegate = null;
340
- return ContinueSentinel;
341
- }
342
-
343
- var info = record.arg;
344
-
345
- if (!info) {
346
- context.method = "throw";
347
- context.arg = new TypeError("iterator result is not an object");
348
- context.delegate = null;
349
- return ContinueSentinel;
350
- }
351
-
352
- if (info.done) {
353
- // Assign the result of the finished delegate to the temporary
354
- // variable specified by delegate.resultName (see delegateYield).
355
- context[delegate.resultName] = info.value; // Resume execution at the desired location (see delegateYield).
356
-
357
- context.next = delegate.nextLoc; // If context.method was "throw" but the delegate handled the
358
- // exception, let the outer generator proceed normally. If
359
- // context.method was "next", forget context.arg since it has been
360
- // "consumed" by the delegate iterator. If context.method was
361
- // "return", allow the original .return call to continue in the
362
- // outer generator.
363
-
364
- if (context.method !== "return") {
365
- context.method = "next";
366
- context.arg = undefined$1;
367
- }
368
- } else {
369
- // Re-yield the result returned by the delegate method.
370
- return info;
371
- } // The delegate iterator is finished, so forget it and continue with
372
- // the outer generator.
373
-
374
-
375
- context.delegate = null;
376
- return ContinueSentinel;
377
- } // Define Generator.prototype.{next,throw,return} in terms of the
378
- // unified ._invoke helper method.
379
-
380
-
381
- defineIteratorMethods(Gp);
382
- Gp[toStringTagSymbol] = "Generator"; // A Generator should always return itself as the iterator object when the
383
- // @@iterator function is called on it. Some browsers' implementations of the
384
- // iterator prototype chain incorrectly implement this, causing the Generator
385
- // object to not be returned from this call. This ensures that doesn't happen.
386
- // See https://github.com/facebook/regenerator/issues/274 for more details.
387
-
388
- Gp[iteratorSymbol] = function () {
389
- return this;
390
- };
391
-
392
- Gp.toString = function () {
393
- return "[object Generator]";
394
- };
395
-
396
- function pushTryEntry(locs) {
397
- var entry = {
398
- tryLoc: locs[0]
399
- };
400
-
401
- if (1 in locs) {
402
- entry.catchLoc = locs[1];
403
- }
404
-
405
- if (2 in locs) {
406
- entry.finallyLoc = locs[2];
407
- entry.afterLoc = locs[3];
408
- }
409
-
410
- this.tryEntries.push(entry);
411
- }
412
-
413
- function resetTryEntry(entry) {
414
- var record = entry.completion || {};
415
- record.type = "normal";
416
- delete record.arg;
417
- entry.completion = record;
418
- }
419
-
420
- function Context(tryLocsList) {
421
- // The root entry object (effectively a try statement without a catch
422
- // or a finally block) gives us a place to store values thrown from
423
- // locations where there is no enclosing try statement.
424
- this.tryEntries = [{
425
- tryLoc: "root"
426
- }];
427
- tryLocsList.forEach(pushTryEntry, this);
428
- this.reset(true);
429
- }
430
-
431
- exports.keys = function (object) {
432
- var keys = [];
433
-
434
- for (var key in object) {
435
- keys.push(key);
436
- }
437
-
438
- keys.reverse(); // Rather than returning an object with a next method, we keep
439
- // things simple and return the next function itself.
440
-
441
- return function next() {
442
- while (keys.length) {
443
- var key = keys.pop();
444
-
445
- if (key in object) {
446
- next.value = key;
447
- next.done = false;
448
- return next;
449
- }
450
- } // To avoid creating an additional object, we just hang the .value
451
- // and .done properties off the next function object itself. This
452
- // also ensures that the minifier will not anonymize the function.
453
-
454
-
455
- next.done = true;
456
- return next;
457
- };
458
- };
459
-
460
- function values(iterable) {
461
- if (iterable) {
462
- var iteratorMethod = iterable[iteratorSymbol];
463
-
464
- if (iteratorMethod) {
465
- return iteratorMethod.call(iterable);
466
- }
467
-
468
- if (typeof iterable.next === "function") {
469
- return iterable;
470
- }
471
-
472
- if (!isNaN(iterable.length)) {
473
- var i = -1,
474
- next = function next() {
475
- while (++i < iterable.length) {
476
- if (hasOwn.call(iterable, i)) {
477
- next.value = iterable[i];
478
- next.done = false;
479
- return next;
480
- }
481
- }
482
-
483
- next.value = undefined$1;
484
- next.done = true;
485
- return next;
486
- };
487
-
488
- return next.next = next;
489
- }
490
- } // Return an iterator with no values.
491
-
492
-
493
- return {
494
- next: doneResult
495
- };
496
- }
497
-
498
- exports.values = values;
499
-
500
- function doneResult() {
501
- return {
502
- value: undefined$1,
503
- done: true
504
- };
505
- }
506
-
507
- Context.prototype = {
508
- constructor: Context,
509
- reset: function (skipTempReset) {
510
- this.prev = 0;
511
- this.next = 0; // Resetting context._sent for legacy support of Babel's
512
- // function.sent implementation.
513
-
514
- this.sent = this._sent = undefined$1;
515
- this.done = false;
516
- this.delegate = null;
517
- this.method = "next";
518
- this.arg = undefined$1;
519
- this.tryEntries.forEach(resetTryEntry);
520
-
521
- if (!skipTempReset) {
522
- for (var name in this) {
523
- // Not sure about the optimal order of these conditions:
524
- if (name.charAt(0) === "t" && hasOwn.call(this, name) && !isNaN(+name.slice(1))) {
525
- this[name] = undefined$1;
526
- }
527
- }
528
- }
529
- },
530
- stop: function () {
531
- this.done = true;
532
- var rootEntry = this.tryEntries[0];
533
- var rootRecord = rootEntry.completion;
534
-
535
- if (rootRecord.type === "throw") {
536
- throw rootRecord.arg;
537
- }
538
-
539
- return this.rval;
540
- },
541
- dispatchException: function (exception) {
542
- if (this.done) {
543
- throw exception;
544
- }
545
-
546
- var context = this;
547
-
548
- function handle(loc, caught) {
549
- record.type = "throw";
550
- record.arg = exception;
551
- context.next = loc;
552
-
553
- if (caught) {
554
- // If the dispatched exception was caught by a catch block,
555
- // then let that catch block handle the exception normally.
556
- context.method = "next";
557
- context.arg = undefined$1;
558
- }
559
-
560
- return !!caught;
561
- }
562
-
563
- for (var i = this.tryEntries.length - 1; i >= 0; --i) {
564
- var entry = this.tryEntries[i];
565
- var record = entry.completion;
566
-
567
- if (entry.tryLoc === "root") {
568
- // Exception thrown outside of any try block that could handle
569
- // it, so set the completion value of the entire function to
570
- // throw the exception.
571
- return handle("end");
572
- }
573
-
574
- if (entry.tryLoc <= this.prev) {
575
- var hasCatch = hasOwn.call(entry, "catchLoc");
576
- var hasFinally = hasOwn.call(entry, "finallyLoc");
577
-
578
- if (hasCatch && hasFinally) {
579
- if (this.prev < entry.catchLoc) {
580
- return handle(entry.catchLoc, true);
581
- } else if (this.prev < entry.finallyLoc) {
582
- return handle(entry.finallyLoc);
583
- }
584
- } else if (hasCatch) {
585
- if (this.prev < entry.catchLoc) {
586
- return handle(entry.catchLoc, true);
587
- }
588
- } else if (hasFinally) {
589
- if (this.prev < entry.finallyLoc) {
590
- return handle(entry.finallyLoc);
591
- }
592
- } else {
593
- throw new Error("try statement without catch or finally");
594
- }
595
- }
596
- }
597
- },
598
- abrupt: function (type, arg) {
599
- for (var i = this.tryEntries.length - 1; i >= 0; --i) {
600
- var entry = this.tryEntries[i];
601
-
602
- if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) {
603
- var finallyEntry = entry;
604
- break;
605
- }
606
- }
607
-
608
- if (finallyEntry && (type === "break" || type === "continue") && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc) {
609
- // Ignore the finally entry if control is not jumping to a
610
- // location outside the try/catch block.
611
- finallyEntry = null;
612
- }
613
-
614
- var record = finallyEntry ? finallyEntry.completion : {};
615
- record.type = type;
616
- record.arg = arg;
617
-
618
- if (finallyEntry) {
619
- this.method = "next";
620
- this.next = finallyEntry.finallyLoc;
621
- return ContinueSentinel;
622
- }
623
-
624
- return this.complete(record);
625
- },
626
- complete: function (record, afterLoc) {
627
- if (record.type === "throw") {
628
- throw record.arg;
629
- }
630
-
631
- if (record.type === "break" || record.type === "continue") {
632
- this.next = record.arg;
633
- } else if (record.type === "return") {
634
- this.rval = this.arg = record.arg;
635
- this.method = "return";
636
- this.next = "end";
637
- } else if (record.type === "normal" && afterLoc) {
638
- this.next = afterLoc;
639
- }
640
-
641
- return ContinueSentinel;
642
- },
643
- finish: function (finallyLoc) {
644
- for (var i = this.tryEntries.length - 1; i >= 0; --i) {
645
- var entry = this.tryEntries[i];
646
-
647
- if (entry.finallyLoc === finallyLoc) {
648
- this.complete(entry.completion, entry.afterLoc);
649
- resetTryEntry(entry);
650
- return ContinueSentinel;
651
- }
652
- }
653
- },
654
- "catch": function (tryLoc) {
655
- for (var i = this.tryEntries.length - 1; i >= 0; --i) {
656
- var entry = this.tryEntries[i];
657
-
658
- if (entry.tryLoc === tryLoc) {
659
- var record = entry.completion;
660
-
661
- if (record.type === "throw") {
662
- var thrown = record.arg;
663
- resetTryEntry(entry);
664
- }
665
-
666
- return thrown;
667
- }
668
- } // The context.catch method must only be called with a location
669
- // argument that corresponds to a known catch block.
670
-
671
-
672
- throw new Error("illegal catch attempt");
673
- },
674
- delegateYield: function (iterable, resultName, nextLoc) {
675
- this.delegate = {
676
- iterator: values(iterable),
677
- resultName: resultName,
678
- nextLoc: nextLoc
679
- };
680
-
681
- if (this.method === "next") {
682
- // Deliberately forget the last sent value so that we don't
683
- // accidentally pass it on to the delegate.
684
- this.arg = undefined$1;
685
- }
686
-
687
- return ContinueSentinel;
688
- }
689
- }; // Regardless of whether this script is executing as a CommonJS module
690
- // or not, return the runtime object so that we can declare the variable
691
- // regeneratorRuntime in the outer scope, which allows this module to be
692
- // injected easily by `bin/regenerator --include-runtime script.js`.
693
-
694
- return exports;
695
- }( // If this script is executing as a CommonJS module, use module.exports
696
- // as the regeneratorRuntime namespace. Otherwise create a new empty
697
- // object. Either way, the resulting object will be used to initialize
698
- // the regeneratorRuntime variable at the top of this file.
699
- module.exports );
700
-
701
- try {
702
- regeneratorRuntime = runtime;
703
- } catch (accidentalStrictMode) {
704
- // This module should not be running in strict mode, so the above
705
- // assignment should always work unless something is misconfigured. Just
706
- // in case runtime.js accidentally runs in strict mode, we can escape
707
- // strict mode using a global Function call. This could conceivably fail
708
- // if a Content Security Policy forbids using Function, but in that case
709
- // the proper solution is to fix the accidental strict mode problem. If
710
- // you've misconfigured your bundler to force strict mode and applied a
711
- // CSP to forbid Function, and you're not willing to fix either of those
712
- // problems, please detail your unique predicament in a GitHub issue.
713
- Function("r", "regeneratorRuntime = r")(runtime);
714
- }
715
- });
716
-
717
- var regenerator = runtime_1;
718
-
719
- const styleProps = ['background-repeat', 'background-origin', 'background-position', 'background-color', 'background-image', 'background-size', 'border-width', 'border-color', 'border-style', 'color', 'display', 'font-size', 'line-height', 'margin', 'opacity', 'overflow', 'padding', 'visibility'];
720
- const rectProps = ['width', 'height', 'top', 'left'];
721
- const ignoredTagNames = ['HEAD', 'SCRIPT'];
722
- var defaultDomProps = {
723
- styleProps,
724
- rectProps,
725
- ignoredTagNames
726
- };
727
-
728
- const bgImageRe = /url\((?!['"]?:)['"]?([^'")]*)['"]?\)/;
729
-
730
- function getBackgroundImageUrl(cssText) {
731
- const match = cssText ? cssText.match(bgImageRe) : undefined;
732
- return match ? match[1] : match;
733
- }
734
-
735
- var getBackgroundImageUrl_1 = getBackgroundImageUrl;
736
-
737
- const psetTimeout = t => new Promise(res => {
738
- setTimeout(res, t);
739
- });
740
-
741
- function getImageSizes({
742
- bgImages,
743
- timeout = 5000,
744
- Image = window.Image
745
- }) {
746
- return regenerator.async(function getImageSizes$(_context) {
747
- while (1) switch (_context.prev = _context.next) {
748
- case 0:
749
- _context.next = 2;
750
- return regenerator.awrap(Promise.all(window.Array.from(bgImages).map(url => Promise.race([new Promise(resolve => {
751
- const img = new Image();
752
-
753
- img.onload = () => resolve({
754
- url,
755
- width: img.naturalWidth,
756
- height: img.naturalHeight
757
- });
758
-
759
- img.onerror = () => resolve();
760
-
761
- img.src = url;
762
- }), psetTimeout(timeout)]))));
763
-
764
- case 2:
765
- _context.t0 = (images, curr) => {
766
- if (curr) {
767
- images[curr.url] = {
768
- width: curr.width,
769
- height: curr.height
770
- };
771
- }
772
-
773
- return images;
774
- };
775
-
776
- _context.t1 = {};
777
- return _context.abrupt("return", _context.sent.reduce(_context.t0, _context.t1));
778
-
779
- case 5:
780
- case "end":
781
- return _context.stop();
782
- }
783
- });
784
- }
785
-
786
- var getImageSizes_1 = getImageSizes;
787
-
788
- function genXpath(el) {
789
- if (!el.ownerDocument) return ''; // this is the document node
790
-
791
- let xpath = '',
792
- currEl = el,
793
- doc = el.ownerDocument,
794
- frameElement = doc.defaultView.frameElement;
795
-
796
- while (currEl !== doc) {
797
- xpath = `${currEl.tagName}[${getIndex(currEl)}]/${xpath}`;
798
- currEl = currEl.parentNode;
799
- }
800
-
801
- if (frameElement) {
802
- xpath = `${genXpath(frameElement)},${xpath}`;
803
- }
804
-
805
- return xpath.replace(/\/$/, '');
806
- }
807
-
808
- function getIndex(el) {
809
- return window.Array.prototype.filter.call(el.parentNode.childNodes, node => node.tagName === el.tagName).indexOf(el) + 1;
810
- }
811
-
812
- var genXpath_1 = genXpath;
813
-
814
- function absolutizeUrl(url, absoluteUrl) {
815
- return new URL(url, absoluteUrl).href;
816
- }
817
-
818
- var absolutizeUrl_1 = absolutizeUrl;
819
-
820
- function makeGetBundledCssFromCssText({
821
- parseCss,
822
- CSSImportRule,
823
- absolutizeUrl,
824
- getCssFromCache,
825
- unfetchedToken
826
- }) {
827
- return function getBundledCssFromCssText(cssText, styleBaseUrl) {
828
- let unfetchedResources;
829
- let bundledCss = '';
830
-
831
- try {
832
- const styleSheet = parseCss(cssText);
833
-
834
- for (const rule of window.Array.from(styleSheet.cssRules)) {
835
- if (rule instanceof CSSImportRule) {
836
- const nestedUrl = absolutizeUrl(rule.href, styleBaseUrl);
837
- const nestedResource = getCssFromCache(nestedUrl);
838
-
839
- if (nestedResource !== undefined) {
840
- const {
841
- bundledCss: nestedCssText,
842
- unfetchedResources: nestedUnfetchedResources
843
- } = getBundledCssFromCssText(nestedResource, nestedUrl);
844
- nestedUnfetchedResources && (unfetchedResources = new window.Set(nestedUnfetchedResources));
845
- bundledCss = `${nestedCssText}${bundledCss}`;
846
- } else {
847
- unfetchedResources = new window.Set([nestedUrl]);
848
- bundledCss = `\n${unfetchedToken}${nestedUrl}${unfetchedToken}`;
849
- }
850
- }
851
- }
852
- } catch (ex) {
853
- console.log(`error during getBundledCssFromCssText, styleBaseUrl=${styleBaseUrl}`, ex);
854
- }
855
-
856
- bundledCss = `${bundledCss}${getCss(cssText, styleBaseUrl)}`;
857
- return {
858
- bundledCss,
859
- unfetchedResources
860
- };
861
- };
862
- }
863
-
864
- function getCss(newText, url) {
865
- return `\n/** ${url} **/\n${newText}`;
866
- }
867
-
868
- var getBundledCssFromCssText = makeGetBundledCssFromCssText;
869
-
870
- function parseCss(styleContent) {
871
- var doc = document.implementation.createHTMLDocument(''),
872
- styleElement = doc.createElement('style');
873
- styleElement.textContent = styleContent; // the style will only be parsed once it is added to a document
874
-
875
- doc.body.appendChild(styleElement);
876
- return styleElement.sheet;
877
- }
878
-
879
- var parseCss_1 = parseCss;
880
-
881
- function makeFetchCss(fetch) {
882
- return function fetchCss(url) {
883
- var response;
884
- return regenerator.async(function fetchCss$(_context) {
885
- while (1) switch (_context.prev = _context.next) {
886
- case 0:
887
- _context.prev = 0;
888
- _context.next = 3;
889
- return regenerator.awrap(fetch(url, {
890
- cache: 'force-cache'
891
- }));
892
-
893
- case 3:
894
- response = _context.sent;
895
-
896
- if (!response.ok) {
897
- _context.next = 8;
898
- break;
899
- }
900
-
901
- _context.next = 7;
902
- return regenerator.awrap(response.text());
903
-
904
- case 7:
905
- return _context.abrupt("return", _context.sent);
906
-
907
- case 8:
908
- console.log('/failed to fetch (status ' + response.status + ') css from: ' + url + '/');
909
- _context.next = 14;
910
- break;
911
-
912
- case 11:
913
- _context.prev = 11;
914
- _context.t0 = _context["catch"](0);
915
- console.log('/failed to fetch (error ' + _context.t0.toString() + ') css from: ' + url + '/');
916
-
917
- case 14:
918
- case "end":
919
- return _context.stop();
920
- }
921
- }, null, null, [[0, 11]]);
922
- };
923
- }
924
-
925
- var fetchCss = makeFetchCss;
926
-
927
- var getHrefAttr = function getHrefAttr(node) {
928
- const attr = window.Array.from(node.attributes).find(attr => attr.name.toLowerCase() === 'href');
929
- return attr && attr.value;
930
- };
931
-
932
- var isLinkToStyleSheet = function isLinkToStyleSheet(node) {
933
- return node.nodeName && node.nodeName.toUpperCase() === 'LINK' && node.attributes && window.Array.from(node.attributes).find(attr => attr.name.toLowerCase() === 'rel' && attr.value.toLowerCase() === 'stylesheet');
934
- };
935
-
936
- function isDataUrl(url) {
937
- return url && url.startsWith('data:');
938
- }
939
-
940
- var isDataUrl_1 = isDataUrl;
941
-
942
- function makeExtractCssFromNode({
943
- getCssFromCache,
944
- absolutizeUrl
945
- }) {
946
- return function extractCssFromNode(node, baseUrl) {
947
- let cssText, styleBaseUrl, isUnfetched;
948
-
949
- if (isStyleElement(node)) {
950
- cssText = window.Array.from(node.childNodes).map(node => node.nodeValue).join('');
951
- styleBaseUrl = baseUrl;
952
- } else if (isLinkToStyleSheet(node)) {
953
- const href = getHrefAttr(node);
954
-
955
- if (!isDataUrl_1(href)) {
956
- styleBaseUrl = absolutizeUrl(href, baseUrl);
957
- cssText = getCssFromCache(styleBaseUrl);
958
- } else {
959
- styleBaseUrl = baseUrl;
960
- cssText = href.match(/,(.+)/)[1];
961
- }
962
-
963
- isUnfetched = cssText === undefined;
964
- }
965
-
966
- return {
967
- cssText,
968
- styleBaseUrl,
969
- isUnfetched
970
- };
971
- };
972
- }
973
-
974
- function isStyleElement(node) {
975
- return node.nodeName && node.nodeName.toUpperCase() === 'STYLE';
976
- }
977
-
978
- var extractCssFromNode = makeExtractCssFromNode;
979
-
980
- function makeCaptureNodeCss({
981
- extractCssFromNode,
982
- getBundledCssFromCssText,
983
- unfetchedToken
984
- }) {
985
- return function captureNodeCss(node, baseUrl) {
986
- const {
987
- styleBaseUrl,
988
- cssText,
989
- isUnfetched
990
- } = extractCssFromNode(node, baseUrl);
991
- let unfetchedResources;
992
- let bundledCss = '';
993
-
994
- if (cssText) {
995
- const {
996
- bundledCss: nestedCss,
997
- unfetchedResources: nestedUnfetched
998
- } = getBundledCssFromCssText(cssText, styleBaseUrl);
999
- bundledCss += nestedCss;
1000
- unfetchedResources = new window.Set(nestedUnfetched);
1001
- } else if (isUnfetched) {
1002
- bundledCss += `${unfetchedToken}${styleBaseUrl}${unfetchedToken}`;
1003
- unfetchedResources = new window.Set([styleBaseUrl]);
1004
- }
1005
-
1006
- return {
1007
- bundledCss,
1008
- unfetchedResources
1009
- };
1010
- };
1011
- }
1012
-
1013
- var captureNodeCss = makeCaptureNodeCss;
1014
-
1015
- const NODE_TYPES = {
1016
- ELEMENT: 1,
1017
- TEXT: 3
1018
- };
1019
- var nodeTypes = {
1020
- NODE_TYPES
1021
- };
1022
-
1023
- const {
1024
- NODE_TYPES: NODE_TYPES$1
1025
- } = nodeTypes;
1026
-
1027
- function makePrefetchAllCss(fetchCss) {
1028
- return function prefetchAllCss(doc = document) {
1029
- var cssMap, start, promises, fetchNodeCss, fetchBundledCss, doFetchAllCssFromFrame;
1030
- return regenerator.async(function prefetchAllCss$(_context6) {
1031
- while (1) switch (_context6.prev = _context6.next) {
1032
- case 0:
1033
- doFetchAllCssFromFrame = function _ref3(frameDoc, cssMap, promises) {
1034
- fetchAllCssFromNode(frameDoc.documentElement);
1035
-
1036
- function fetchAllCssFromNode(node) {
1037
- promises.push(fetchNodeCss(node, frameDoc.location.href, cssMap));
1038
-
1039
- switch (node.nodeType) {
1040
- case NODE_TYPES$1.ELEMENT:
1041
- {
1042
- const tagName = node.tagName.toUpperCase();
1043
-
1044
- if (tagName === 'IFRAME') {
1045
- return fetchAllCssFromIframe(node);
1046
- } else {
1047
- return fetchAllCssFromElement(node);
1048
- }
1049
- }
1050
- }
1051
- }
1052
-
1053
- function fetchAllCssFromElement(el) {
1054
- return regenerator.async(function fetchAllCssFromElement$(_context4) {
1055
- while (1) switch (_context4.prev = _context4.next) {
1056
- case 0:
1057
- window.Array.prototype.map.call(el.childNodes, fetchAllCssFromNode);
1058
-
1059
- case 1:
1060
- case "end":
1061
- return _context4.stop();
1062
- }
1063
- });
1064
- }
1065
-
1066
- function fetchAllCssFromIframe(el) {
1067
- return regenerator.async(function fetchAllCssFromIframe$(_context5) {
1068
- while (1) switch (_context5.prev = _context5.next) {
1069
- case 0:
1070
- fetchAllCssFromElement(el);
1071
-
1072
- try {
1073
- doFetchAllCssFromFrame(el.contentDocument, cssMap, promises);
1074
- } catch (ex) {
1075
- console.log(ex);
1076
- }
1077
-
1078
- case 2:
1079
- case "end":
1080
- return _context5.stop();
1081
- }
1082
- });
1083
- }
1084
- };
1085
-
1086
- fetchBundledCss = function _ref2(cssText, resourceUrl, cssMap) {
1087
- var styleSheet, promises, rule;
1088
- return regenerator.async(function fetchBundledCss$(_context3) {
1089
- while (1) switch (_context3.prev = _context3.next) {
1090
- case 0:
1091
- _context3.prev = 0;
1092
- styleSheet = parseCss_1(cssText);
1093
- promises = [];
1094
-
1095
- for (rule of window.Array.from(styleSheet.cssRules)) {
1096
- if (rule instanceof CSSImportRule) {
1097
- promises.push((() => {
1098
- var nestedUrl, cssText;
1099
- return regenerator.async(function _callee$(_context2) {
1100
- while (1) switch (_context2.prev = _context2.next) {
1101
- case 0:
1102
- nestedUrl = absolutizeUrl_1(rule.href, resourceUrl);
1103
- _context2.next = 3;
1104
- return regenerator.awrap(fetchCss(nestedUrl));
1105
-
1106
- case 3:
1107
- cssText = _context2.sent;
1108
- cssMap[nestedUrl] = cssText;
1109
-
1110
- if (!(cssText !== undefined)) {
1111
- _context2.next = 8;
1112
- break;
1113
- }
1114
-
1115
- _context2.next = 8;
1116
- return regenerator.awrap(fetchBundledCss(cssText, nestedUrl, cssMap));
1117
-
1118
- case 8:
1119
- case "end":
1120
- return _context2.stop();
1121
- }
1122
- });
1123
- })());
1124
- }
1125
- }
1126
-
1127
- _context3.next = 6;
1128
- return regenerator.awrap(Promise.all(promises));
1129
-
1130
- case 6:
1131
- _context3.next = 11;
1132
- break;
1133
-
1134
- case 8:
1135
- _context3.prev = 8;
1136
- _context3.t0 = _context3["catch"](0);
1137
- console.log(`error during fetchBundledCss, resourceUrl=${resourceUrl}`, _context3.t0);
1138
-
1139
- case 11:
1140
- case "end":
1141
- return _context3.stop();
1142
- }
1143
- }, null, null, [[0, 8]]);
1144
- };
1145
-
1146
- fetchNodeCss = function _ref(node, baseUrl, cssMap) {
1147
- var cssText, resourceUrl;
1148
- return regenerator.async(function fetchNodeCss$(_context) {
1149
- while (1) switch (_context.prev = _context.next) {
1150
- case 0:
1151
- if (!isLinkToStyleSheet(node)) {
1152
- _context.next = 6;
1153
- break;
1154
- }
1155
-
1156
- resourceUrl = absolutizeUrl_1(getHrefAttr(node), baseUrl);
1157
- _context.next = 4;
1158
- return regenerator.awrap(fetchCss(resourceUrl));
1159
-
1160
- case 4:
1161
- cssText = _context.sent;
1162
-
1163
- if (cssText !== undefined) {
1164
- cssMap[resourceUrl] = cssText;
1165
- }
1166
-
1167
- case 6:
1168
- if (!cssText) {
1169
- _context.next = 9;
1170
- break;
1171
- }
1172
-
1173
- _context.next = 9;
1174
- return regenerator.awrap(fetchBundledCss(cssText, resourceUrl, cssMap));
1175
-
1176
- case 9:
1177
- case "end":
1178
- return _context.stop();
1179
- }
1180
- });
1181
- };
1182
-
1183
- cssMap = {};
1184
- start = Date.now();
1185
- promises = [];
1186
- doFetchAllCssFromFrame(doc, cssMap, promises);
1187
- _context6.next = 9;
1188
- return regenerator.awrap(Promise.all(promises));
1189
-
1190
- case 9:
1191
- console.log('[prefetchAllCss]', Date.now() - start);
1192
- return _context6.abrupt("return", function fetchCssSync(url) {
1193
- return cssMap[url];
1194
- });
1195
-
1196
- case 11:
1197
- case "end":
1198
- return _context6.stop();
1199
- }
1200
- });
1201
- };
1202
- }
1203
-
1204
- var prefetchAllCss = makePrefetchAllCss;
1205
-
1206
- const {
1207
- NODE_TYPES: NODE_TYPES$2
1208
- } = nodeTypes;
1209
- const API_VERSION = '1.1.0';
1210
-
1211
- function captureFrame({
1212
- styleProps,
1213
- rectProps,
1214
- ignoredTagNames
1215
- } = defaultDomProps, doc = document, addStats = false) {
1216
- var performance, startTime, endTime, promises, unfetchedResources, iframeCors, iframeToken, unfetchedToken, separator, prefetchAllCss$1, getCssFromCache, getBundledCssFromCssText$1, extractCssFromNode$1, captureNodeCss$1, capturedFrame, iframePrefix, unfetchedPrefix, metaPrefix, stats, ret, filter, notEmptyObj, captureTextNode, doCaptureFrame;
1217
- return regenerator.async(function captureFrame$(_context) {
1218
- while (1) switch (_context.prev = _context.next) {
1219
- case 0:
1220
- doCaptureFrame = function _ref7(frameDoc) {
1221
- const bgImages = new window.Set();
1222
- let bundledCss = '';
1223
- const ret = captureNode(frameDoc.documentElement);
1224
- ret.css = bundledCss;
1225
- promises.push(getImageSizes_1({
1226
- bgImages
1227
- }).then(images => ret.images = images));
1228
- return ret;
1229
-
1230
- function captureNode(node) {
1231
- const {
1232
- bundledCss: nodeCss,
1233
- unfetchedResources: nodeUnfetched
1234
- } = captureNodeCss$1(node, frameDoc.location.href);
1235
- bundledCss += nodeCss;
1236
- if (nodeUnfetched) for (const elem of nodeUnfetched) unfetchedResources.add(elem);
1237
-
1238
- switch (node.nodeType) {
1239
- case NODE_TYPES$2.TEXT:
1240
- {
1241
- return captureTextNode(node);
1242
- }
1243
-
1244
- case NODE_TYPES$2.ELEMENT:
1245
- {
1246
- const tagName = node.tagName.toUpperCase();
1247
-
1248
- if (tagName === 'IFRAME') {
1249
- return iframeToJSON(node);
1250
- } else {
1251
- return elementToJSON(node);
1252
- }
1253
- }
1254
-
1255
- default:
1256
- {
1257
- return null;
1258
- }
1259
- }
1260
- }
1261
-
1262
- function elementToJSON(el) {
1263
- const childNodes = window.Array.prototype.map.call(el.childNodes, captureNode).filter(filter);
1264
- const tagName = el.tagName.toUpperCase();
1265
- if (ignoredTagNames.indexOf(tagName) > -1) return null;
1266
- const computedStyle = window.getComputedStyle(el);
1267
- const boundingClientRect = el.getBoundingClientRect();
1268
- const style = {};
1269
-
1270
- for (const p of styleProps) style[p] = computedStyle.getPropertyValue(p);
1271
-
1272
- if (!style['border-width']) {
1273
- style['border-width'] = `${computedStyle.getPropertyValue('border-top-width')} ${computedStyle.getPropertyValue('border-right-width')} ${computedStyle.getPropertyValue('border-bottom-width')} ${computedStyle.getPropertyValue('border-left-width')}`;
1274
- }
1275
-
1276
- const rect = {};
1277
-
1278
- for (const p of rectProps) rect[p] = boundingClientRect[p];
1279
-
1280
- const attributes = window.Array.from(el.attributes).map(a => ({
1281
- key: a.name,
1282
- value: a.value
1283
- })).reduce((obj, attr) => {
1284
- obj[attr.key] = attr.value;
1285
- return obj;
1286
- }, {});
1287
- const bgImage = getBackgroundImageUrl_1(computedStyle.getPropertyValue('background-image'));
1288
-
1289
- if (bgImage) {
1290
- bgImages.add(bgImage);
1291
- }
1292
-
1293
- return {
1294
- tagName,
1295
- style: notEmptyObj(style),
1296
- rect: notEmptyObj(rect),
1297
- attributes: notEmptyObj(attributes),
1298
- childNodes
1299
- };
1300
- }
1301
-
1302
- function iframeToJSON(el) {
1303
- const obj = elementToJSON(el);
1304
- let doc;
1305
-
1306
- try {
1307
- doc = el.contentDocument;
1308
- } catch (ex) {
1309
- markFrameAsCors();
1310
- return obj;
1311
- }
1312
-
1313
- try {
1314
- if (doc) {
1315
- obj.childNodes = [doCaptureFrame(el.contentDocument)];
1316
- } else {
1317
- markFrameAsCors();
1318
- }
1319
- } catch (ex) {
1320
- console.log('error in iframeToJSON', ex);
1321
- }
1322
-
1323
- return obj;
1324
-
1325
- function markFrameAsCors() {
1326
- const xpath = genXpath_1(el);
1327
- iframeCors.push(xpath);
1328
- obj.childNodes = [`${iframeToken}${xpath}${iframeToken}`];
1329
- }
1330
- }
1331
- };
1332
-
1333
- captureTextNode = function _ref6(node) {
1334
- return {
1335
- tagName: '#text',
1336
- text: node.textContent
1337
- };
1338
- };
1339
-
1340
- notEmptyObj = function _ref5(obj) {
1341
- return window.Object.keys(obj).length ? obj : undefined;
1342
- };
1343
-
1344
- filter = function _ref4(x) {
1345
- return !!x;
1346
- };
1347
-
1348
- stats = function _ref3() {
1349
- if (!addStats) {
1350
- return '';
1351
- }
1352
-
1353
- return `\n${separator}\n${JSON.stringify(performance)}`;
1354
- };
1355
-
1356
- endTime = function _ref2(obj) {
1357
- obj.endTime = Date.now();
1358
- obj.ellapsedTime = obj.endTime - obj.startTime;
1359
- };
1360
-
1361
- startTime = function _ref(obj) {
1362
- obj.startTime = Date.now();
1363
- };
1364
-
1365
- performance = {
1366
- total: {},
1367
- prefetchCss: {},
1368
- doCaptureFrame: {},
1369
- waitForImages: {}
1370
- };
1371
- promises = [];
1372
- startTime(performance.total);
1373
- unfetchedResources = new window.Set();
1374
- iframeCors = [];
1375
- iframeToken = '@@@@@';
1376
- unfetchedToken = '#####';
1377
- separator = '-----';
1378
- startTime(performance.prefetchCss);
1379
- prefetchAllCss$1 = prefetchAllCss(fetchCss(fetch));
1380
- _context.next = 19;
1381
- return regenerator.awrap(prefetchAllCss$1(doc));
1382
-
1383
- case 19:
1384
- getCssFromCache = _context.sent;
1385
- endTime(performance.prefetchCss);
1386
- getBundledCssFromCssText$1 = getBundledCssFromCssText({
1387
- parseCss: parseCss_1,
1388
- CSSImportRule,
1389
- getCssFromCache,
1390
- absolutizeUrl: absolutizeUrl_1,
1391
- unfetchedToken
1392
- });
1393
- extractCssFromNode$1 = extractCssFromNode({
1394
- getCssFromCache,
1395
- absolutizeUrl: absolutizeUrl_1
1396
- });
1397
- captureNodeCss$1 = captureNodeCss({
1398
- extractCssFromNode: extractCssFromNode$1,
1399
- getBundledCssFromCssText: getBundledCssFromCssText$1,
1400
- unfetchedToken
1401
- });
1402
- startTime(performance.doCaptureFrame);
1403
- capturedFrame = doCaptureFrame(doc);
1404
- endTime(performance.doCaptureFrame);
1405
- startTime(performance.waitForImages);
1406
- _context.next = 30;
1407
- return regenerator.awrap(Promise.all(promises));
1408
-
1409
- case 30:
1410
- endTime(performance.waitForImages); // Note: Change the API_VERSION when changing json structure.
1411
-
1412
- capturedFrame.version = API_VERSION;
1413
- capturedFrame.scriptVersion = 'DOM_CAPTURE_SCRIPT_VERSION_TO_BE_REPLACED';
1414
- iframePrefix = iframeCors.length ? `${iframeCors.join('\n')}\n` : '';
1415
- unfetchedPrefix = unfetchedResources.size ? `${Array.from(unfetchedResources).join('\n')}\n` : '';
1416
- metaPrefix = JSON.stringify({
1417
- separator,
1418
- cssStartToken: unfetchedToken,
1419
- cssEndToken: unfetchedToken,
1420
- iframeStartToken: `"${iframeToken}`,
1421
- iframeEndToken: `${iframeToken}"`
1422
- });
1423
- endTime(performance.total);
1424
- ret = `${metaPrefix}\n${unfetchedPrefix}${separator}\n${iframePrefix}${separator}\n${JSON.stringify(capturedFrame)}${stats()}`;
1425
- console.log('[captureFrame]', JSON.stringify(performance));
1426
- return _context.abrupt("return", ret);
1427
-
1428
- case 40:
1429
- case "end":
1430
- return _context.stop();
1431
- }
1432
- });
1433
- }
1434
-
1435
- var captureFrame_1 = captureFrame;
1436
-
1437
- const EYES_NAME_SPACE = '__EYES__APPLITOOLS__';
1438
-
1439
- function captureFrameAndPoll(...args) {
1440
- if (!window[EYES_NAME_SPACE]) {
1441
- window[EYES_NAME_SPACE] = {};
1442
- }
1443
-
1444
- if (!window[EYES_NAME_SPACE].captureDomResult) {
1445
- window[EYES_NAME_SPACE].captureDomResult = {
1446
- status: 'WIP',
1447
- value: null,
1448
- error: null
1449
- };
1450
- captureFrame_1.apply(void 0, args).then(r => (resultObject.status = 'SUCCESS', resultObject.value = r)).catch(e => (resultObject.status = 'ERROR', resultObject.error = e.message));
1451
- }
1452
-
1453
- const resultObject = window[EYES_NAME_SPACE].captureDomResult;
1454
-
1455
- if (resultObject.status === 'SUCCESS') {
1456
- window[EYES_NAME_SPACE].captureDomResult = null;
1457
- }
1458
-
1459
- return JSON.stringify(resultObject);
1460
- }
1461
-
1462
- var captureFrameAndPoll_1 = captureFrameAndPoll;
1463
-
1464
- return captureFrameAndPoll_1;
1465
-
1466
- }());
1467
- return captureFrameAndPoll()
1468
- }