@stablyai/playwright-test 2.0.15 → 2.0.16

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.
@@ -6407,204 +6407,331 @@ function requireWebsocketServer () {
6407
6407
 
6408
6408
  requireWebsocketServer();
6409
6409
 
6410
- const objectToString = Object.prototype.toString;
6411
- const isError = (value) => objectToString.call(value) === "[object Error]";
6412
- const errorMessages = /* @__PURE__ */ new Set([
6413
- "network error",
6414
- // Chrome
6415
- "Failed to fetch",
6416
- // Chrome
6417
- "NetworkError when attempting to fetch resource.",
6418
- // Firefox
6419
- "The Internet connection appears to be offline.",
6420
- // Safari 16
6421
- "Network request failed",
6422
- // `cross-fetch`
6423
- "fetch failed",
6424
- // Undici (Node.js)
6425
- "terminated",
6426
- // Undici (Node.js)
6427
- " A network error occurred.",
6428
- // Bun (WebKit)
6429
- "Network connection lost"
6430
- // Cloudflare Workers (fetch)
6431
- ]);
6432
- function isNetworkError(error) {
6433
- const isValid = error && isError(error) && error.name === "TypeError" && typeof error.message === "string";
6434
- if (!isValid) {
6435
- return false;
6436
- }
6437
- const { message, stack } = error;
6438
- if (message === "Load failed") {
6439
- return stack === void 0 || "__sentry_captured__" in error;
6440
- }
6441
- if (message.startsWith("error sending request for url")) {
6442
- return true;
6443
- }
6444
- return errorMessages.has(message);
6445
- }
6410
+ var pRetry = {exports: {}};
6446
6411
 
6447
- function validateRetries(retries) {
6448
- if (typeof retries === "number") {
6449
- if (retries < 0) {
6450
- throw new TypeError("Expected `retries` to be a non-negative number.");
6451
- }
6452
- if (Number.isNaN(retries)) {
6453
- throw new TypeError("Expected `retries` to be a valid number or Infinity, got NaN.");
6454
- }
6455
- } else if (retries !== void 0) {
6456
- throw new TypeError("Expected `retries` to be a number or Infinity.");
6457
- }
6412
+ var retry$1 = {};
6413
+
6414
+ var retry_operation;
6415
+ var hasRequiredRetry_operation;
6416
+
6417
+ function requireRetry_operation () {
6418
+ if (hasRequiredRetry_operation) return retry_operation;
6419
+ hasRequiredRetry_operation = 1;
6420
+ function RetryOperation(timeouts, options) {
6421
+ if (typeof options === "boolean") {
6422
+ options = { forever: options };
6423
+ }
6424
+ this._originalTimeouts = JSON.parse(JSON.stringify(timeouts));
6425
+ this._timeouts = timeouts;
6426
+ this._options = options || {};
6427
+ this._maxRetryTime = options && options.maxRetryTime || Infinity;
6428
+ this._fn = null;
6429
+ this._errors = [];
6430
+ this._attempts = 1;
6431
+ this._operationTimeout = null;
6432
+ this._operationTimeoutCb = null;
6433
+ this._timeout = null;
6434
+ this._operationStart = null;
6435
+ this._timer = null;
6436
+ if (this._options.forever) {
6437
+ this._cachedTimeouts = this._timeouts.slice(0);
6438
+ }
6439
+ }
6440
+ retry_operation = RetryOperation;
6441
+ RetryOperation.prototype.reset = function() {
6442
+ this._attempts = 1;
6443
+ this._timeouts = this._originalTimeouts.slice(0);
6444
+ };
6445
+ RetryOperation.prototype.stop = function() {
6446
+ if (this._timeout) {
6447
+ clearTimeout(this._timeout);
6448
+ }
6449
+ if (this._timer) {
6450
+ clearTimeout(this._timer);
6451
+ }
6452
+ this._timeouts = [];
6453
+ this._cachedTimeouts = null;
6454
+ };
6455
+ RetryOperation.prototype.retry = function(err) {
6456
+ if (this._timeout) {
6457
+ clearTimeout(this._timeout);
6458
+ }
6459
+ if (!err) {
6460
+ return false;
6461
+ }
6462
+ var currentTime = (/* @__PURE__ */ new Date()).getTime();
6463
+ if (err && currentTime - this._operationStart >= this._maxRetryTime) {
6464
+ this._errors.push(err);
6465
+ this._errors.unshift(new Error("RetryOperation timeout occurred"));
6466
+ return false;
6467
+ }
6468
+ this._errors.push(err);
6469
+ var timeout = this._timeouts.shift();
6470
+ if (timeout === void 0) {
6471
+ if (this._cachedTimeouts) {
6472
+ this._errors.splice(0, this._errors.length - 1);
6473
+ timeout = this._cachedTimeouts.slice(-1);
6474
+ } else {
6475
+ return false;
6476
+ }
6477
+ }
6478
+ var self = this;
6479
+ this._timer = setTimeout(function() {
6480
+ self._attempts++;
6481
+ if (self._operationTimeoutCb) {
6482
+ self._timeout = setTimeout(function() {
6483
+ self._operationTimeoutCb(self._attempts);
6484
+ }, self._operationTimeout);
6485
+ if (self._options.unref) {
6486
+ self._timeout.unref();
6487
+ }
6488
+ }
6489
+ self._fn(self._attempts);
6490
+ }, timeout);
6491
+ if (this._options.unref) {
6492
+ this._timer.unref();
6493
+ }
6494
+ return true;
6495
+ };
6496
+ RetryOperation.prototype.attempt = function(fn, timeoutOps) {
6497
+ this._fn = fn;
6498
+ if (timeoutOps) {
6499
+ if (timeoutOps.timeout) {
6500
+ this._operationTimeout = timeoutOps.timeout;
6501
+ }
6502
+ if (timeoutOps.cb) {
6503
+ this._operationTimeoutCb = timeoutOps.cb;
6504
+ }
6505
+ }
6506
+ var self = this;
6507
+ if (this._operationTimeoutCb) {
6508
+ this._timeout = setTimeout(function() {
6509
+ self._operationTimeoutCb();
6510
+ }, self._operationTimeout);
6511
+ }
6512
+ this._operationStart = (/* @__PURE__ */ new Date()).getTime();
6513
+ this._fn(this._attempts);
6514
+ };
6515
+ RetryOperation.prototype.try = function(fn) {
6516
+ console.log("Using RetryOperation.try() is deprecated");
6517
+ this.attempt(fn);
6518
+ };
6519
+ RetryOperation.prototype.start = function(fn) {
6520
+ console.log("Using RetryOperation.start() is deprecated");
6521
+ this.attempt(fn);
6522
+ };
6523
+ RetryOperation.prototype.start = RetryOperation.prototype.try;
6524
+ RetryOperation.prototype.errors = function() {
6525
+ return this._errors;
6526
+ };
6527
+ RetryOperation.prototype.attempts = function() {
6528
+ return this._attempts;
6529
+ };
6530
+ RetryOperation.prototype.mainError = function() {
6531
+ if (this._errors.length === 0) {
6532
+ return null;
6533
+ }
6534
+ var counts = {};
6535
+ var mainError = null;
6536
+ var mainErrorCount = 0;
6537
+ for (var i = 0; i < this._errors.length; i++) {
6538
+ var error = this._errors[i];
6539
+ var message = error.message;
6540
+ var count = (counts[message] || 0) + 1;
6541
+ counts[message] = count;
6542
+ if (count >= mainErrorCount) {
6543
+ mainError = error;
6544
+ mainErrorCount = count;
6545
+ }
6546
+ }
6547
+ return mainError;
6548
+ };
6549
+ return retry_operation;
6458
6550
  }
6459
- function validateNumberOption(name, value, { min = 0, allowInfinity = false } = {}) {
6460
- if (value === void 0) {
6461
- return;
6462
- }
6463
- if (typeof value !== "number" || Number.isNaN(value)) {
6464
- throw new TypeError(`Expected \`${name}\` to be a number${allowInfinity ? " or Infinity" : ""}.`);
6465
- }
6466
- if (!allowInfinity && !Number.isFinite(value)) {
6467
- throw new TypeError(`Expected \`${name}\` to be a finite number.`);
6468
- }
6469
- if (value < min) {
6470
- throw new TypeError(`Expected \`${name}\` to be \u2265 ${min}.`);
6471
- }
6551
+
6552
+ var hasRequiredRetry$1;
6553
+
6554
+ function requireRetry$1 () {
6555
+ if (hasRequiredRetry$1) return retry$1;
6556
+ hasRequiredRetry$1 = 1;
6557
+ (function (exports$1) {
6558
+ var RetryOperation = requireRetry_operation();
6559
+ exports$1.operation = function(options) {
6560
+ var timeouts = exports$1.timeouts(options);
6561
+ return new RetryOperation(timeouts, {
6562
+ forever: options && (options.forever || options.retries === Infinity),
6563
+ unref: options && options.unref,
6564
+ maxRetryTime: options && options.maxRetryTime
6565
+ });
6566
+ };
6567
+ exports$1.timeouts = function(options) {
6568
+ if (options instanceof Array) {
6569
+ return [].concat(options);
6570
+ }
6571
+ var opts = {
6572
+ retries: 10,
6573
+ factor: 2,
6574
+ minTimeout: 1 * 1e3,
6575
+ maxTimeout: Infinity,
6576
+ randomize: false
6577
+ };
6578
+ for (var key in options) {
6579
+ opts[key] = options[key];
6580
+ }
6581
+ if (opts.minTimeout > opts.maxTimeout) {
6582
+ throw new Error("minTimeout is greater than maxTimeout");
6583
+ }
6584
+ var timeouts = [];
6585
+ for (var i = 0; i < opts.retries; i++) {
6586
+ timeouts.push(this.createTimeout(i, opts));
6587
+ }
6588
+ if (options && options.forever && !timeouts.length) {
6589
+ timeouts.push(this.createTimeout(i, opts));
6590
+ }
6591
+ timeouts.sort(function(a, b) {
6592
+ return a - b;
6593
+ });
6594
+ return timeouts;
6595
+ };
6596
+ exports$1.createTimeout = function(attempt, opts) {
6597
+ var random = opts.randomize ? Math.random() + 1 : 1;
6598
+ var timeout = Math.round(random * Math.max(opts.minTimeout, 1) * Math.pow(opts.factor, attempt));
6599
+ timeout = Math.min(timeout, opts.maxTimeout);
6600
+ return timeout;
6601
+ };
6602
+ exports$1.wrap = function(obj, options, methods) {
6603
+ if (options instanceof Array) {
6604
+ methods = options;
6605
+ options = null;
6606
+ }
6607
+ if (!methods) {
6608
+ methods = [];
6609
+ for (var key in obj) {
6610
+ if (typeof obj[key] === "function") {
6611
+ methods.push(key);
6612
+ }
6613
+ }
6614
+ }
6615
+ for (var i = 0; i < methods.length; i++) {
6616
+ var method = methods[i];
6617
+ var original = obj[method];
6618
+ obj[method] = function retryWrapper(original2) {
6619
+ var op = exports$1.operation(options);
6620
+ var args = Array.prototype.slice.call(arguments, 1);
6621
+ var callback = args.pop();
6622
+ args.push(function(err) {
6623
+ if (op.retry(err)) {
6624
+ return;
6625
+ }
6626
+ if (err) {
6627
+ arguments[0] = op.mainError();
6628
+ }
6629
+ callback.apply(this, arguments);
6630
+ });
6631
+ op.attempt(function() {
6632
+ original2.apply(obj, args);
6633
+ });
6634
+ }.bind(obj, original);
6635
+ obj[method].options = options;
6636
+ }
6637
+ };
6638
+ } (retry$1));
6639
+ return retry$1;
6472
6640
  }
6473
- class AbortError extends Error {
6474
- constructor(message) {
6475
- super();
6476
- if (message instanceof Error) {
6477
- this.originalError = message;
6478
- ({ message } = message);
6479
- } else {
6480
- this.originalError = new Error(message);
6481
- this.originalError.stack = this.stack;
6482
- }
6483
- this.name = "AbortError";
6484
- this.message = message;
6485
- }
6486
- }
6487
- function calculateDelay(retriesConsumed, options) {
6488
- const attempt = Math.max(1, retriesConsumed + 1);
6489
- const random = options.randomize ? Math.random() + 1 : 1;
6490
- let timeout = Math.round(random * options.minTimeout * options.factor ** (attempt - 1));
6491
- timeout = Math.min(timeout, options.maxTimeout);
6492
- return timeout;
6493
- }
6494
- function calculateRemainingTime(start, max) {
6495
- if (!Number.isFinite(max)) {
6496
- return max;
6497
- }
6498
- return max - (performance.now() - start);
6499
- }
6500
- async function onAttemptFailure({ error, attemptNumber, retriesConsumed, startTime, options }) {
6501
- const normalizedError = error instanceof Error ? error : new TypeError(`Non-error was thrown: "${error}". You should only throw errors.`);
6502
- if (normalizedError instanceof AbortError) {
6503
- throw normalizedError.originalError;
6504
- }
6505
- const retriesLeft = Number.isFinite(options.retries) ? Math.max(0, options.retries - retriesConsumed) : options.retries;
6506
- const maxRetryTime = options.maxRetryTime ?? Number.POSITIVE_INFINITY;
6507
- const context = Object.freeze({
6508
- error: normalizedError,
6509
- attemptNumber,
6510
- retriesLeft,
6511
- retriesConsumed
6512
- });
6513
- await options.onFailedAttempt(context);
6514
- if (calculateRemainingTime(startTime, maxRetryTime) <= 0) {
6515
- throw normalizedError;
6516
- }
6517
- const consumeRetry = await options.shouldConsumeRetry(context);
6518
- const remainingTime = calculateRemainingTime(startTime, maxRetryTime);
6519
- if (remainingTime <= 0 || retriesLeft <= 0) {
6520
- throw normalizedError;
6521
- }
6522
- if (normalizedError instanceof TypeError && !isNetworkError(normalizedError)) {
6523
- if (consumeRetry) {
6524
- throw normalizedError;
6525
- }
6526
- options.signal?.throwIfAborted();
6527
- return false;
6528
- }
6529
- if (!await options.shouldRetry(context)) {
6530
- throw normalizedError;
6531
- }
6532
- if (!consumeRetry) {
6533
- options.signal?.throwIfAborted();
6534
- return false;
6535
- }
6536
- const delayTime = calculateDelay(retriesConsumed, options);
6537
- const finalDelay = Math.min(delayTime, remainingTime);
6538
- options.signal?.throwIfAborted();
6539
- if (finalDelay > 0) {
6540
- await new Promise((resolve, reject) => {
6541
- const onAbort = () => {
6542
- clearTimeout(timeoutToken);
6543
- options.signal?.removeEventListener("abort", onAbort);
6544
- reject(options.signal.reason);
6545
- };
6546
- const timeoutToken = setTimeout(() => {
6547
- options.signal?.removeEventListener("abort", onAbort);
6548
- resolve();
6549
- }, finalDelay);
6550
- if (options.unref) {
6551
- timeoutToken.unref?.();
6552
- }
6553
- options.signal?.addEventListener("abort", onAbort, { once: true });
6554
- });
6555
- }
6556
- options.signal?.throwIfAborted();
6557
- return true;
6641
+
6642
+ var retry;
6643
+ var hasRequiredRetry;
6644
+
6645
+ function requireRetry () {
6646
+ if (hasRequiredRetry) return retry;
6647
+ hasRequiredRetry = 1;
6648
+ retry = requireRetry$1();
6649
+ return retry;
6558
6650
  }
6559
- async function pRetry(input, options = {}) {
6560
- options = { ...options };
6561
- validateRetries(options.retries);
6562
- if (Object.hasOwn(options, "forever")) {
6563
- throw new Error("The `forever` option is no longer supported. For many use-cases, you can set `retries: Infinity` instead.");
6564
- }
6565
- options.retries ??= 10;
6566
- options.factor ??= 2;
6567
- options.minTimeout ??= 1e3;
6568
- options.maxTimeout ??= Number.POSITIVE_INFINITY;
6569
- options.maxRetryTime ??= Number.POSITIVE_INFINITY;
6570
- options.randomize ??= false;
6571
- options.onFailedAttempt ??= () => {
6572
- };
6573
- options.shouldRetry ??= () => true;
6574
- options.shouldConsumeRetry ??= () => true;
6575
- validateNumberOption("factor", options.factor, { min: 0, allowInfinity: false });
6576
- validateNumberOption("minTimeout", options.minTimeout, { min: 0, allowInfinity: false });
6577
- validateNumberOption("maxTimeout", options.maxTimeout, { min: 0, allowInfinity: true });
6578
- validateNumberOption("maxRetryTime", options.maxRetryTime, { min: 0, allowInfinity: true });
6579
- if (!(options.factor > 0)) {
6580
- options.factor = 1;
6581
- }
6582
- options.signal?.throwIfAborted();
6583
- let attemptNumber = 0;
6584
- let retriesConsumed = 0;
6585
- const startTime = performance.now();
6586
- while (Number.isFinite(options.retries) ? retriesConsumed <= options.retries : true) {
6587
- attemptNumber++;
6588
- try {
6589
- options.signal?.throwIfAborted();
6590
- const result = await input(attemptNumber);
6591
- options.signal?.throwIfAborted();
6592
- return result;
6593
- } catch (error) {
6594
- if (await onAttemptFailure({
6595
- error,
6596
- attemptNumber,
6597
- retriesConsumed,
6598
- startTime,
6599
- options
6600
- })) {
6601
- retriesConsumed++;
6602
- }
6603
- }
6604
- }
6605
- throw new Error("Retry attempts exhausted without throwing an error.");
6651
+
6652
+ var hasRequiredPRetry;
6653
+
6654
+ function requirePRetry () {
6655
+ if (hasRequiredPRetry) return pRetry.exports;
6656
+ hasRequiredPRetry = 1;
6657
+ const retry = requireRetry();
6658
+ const networkErrorMsgs = [
6659
+ "Failed to fetch",
6660
+ // Chrome
6661
+ "NetworkError when attempting to fetch resource.",
6662
+ // Firefox
6663
+ "The Internet connection appears to be offline.",
6664
+ // Safari
6665
+ "Network request failed"
6666
+ // `cross-fetch`
6667
+ ];
6668
+ class AbortError extends Error {
6669
+ constructor(message) {
6670
+ super();
6671
+ if (message instanceof Error) {
6672
+ this.originalError = message;
6673
+ ({ message } = message);
6674
+ } else {
6675
+ this.originalError = new Error(message);
6676
+ this.originalError.stack = this.stack;
6677
+ }
6678
+ this.name = "AbortError";
6679
+ this.message = message;
6680
+ }
6681
+ }
6682
+ const decorateErrorWithCounts = (error, attemptNumber, options) => {
6683
+ const retriesLeft = options.retries - (attemptNumber - 1);
6684
+ error.attemptNumber = attemptNumber;
6685
+ error.retriesLeft = retriesLeft;
6686
+ return error;
6687
+ };
6688
+ const isNetworkError = (errorMessage) => networkErrorMsgs.includes(errorMessage);
6689
+ const pRetry$1 = (input, options) => new Promise((resolve, reject) => {
6690
+ options = {
6691
+ onFailedAttempt: () => {
6692
+ },
6693
+ retries: 10,
6694
+ ...options
6695
+ };
6696
+ const operation = retry.operation(options);
6697
+ operation.attempt(async (attemptNumber) => {
6698
+ try {
6699
+ resolve(await input(attemptNumber));
6700
+ } catch (error) {
6701
+ if (!(error instanceof Error)) {
6702
+ reject(new TypeError(`Non-error was thrown: "${error}". You should only throw errors.`));
6703
+ return;
6704
+ }
6705
+ if (error instanceof AbortError) {
6706
+ operation.stop();
6707
+ reject(error.originalError);
6708
+ } else if (error instanceof TypeError && !isNetworkError(error.message)) {
6709
+ operation.stop();
6710
+ reject(error);
6711
+ } else {
6712
+ decorateErrorWithCounts(error, attemptNumber, options);
6713
+ try {
6714
+ await options.onFailedAttempt(error);
6715
+ } catch (error2) {
6716
+ reject(error2);
6717
+ return;
6718
+ }
6719
+ if (!operation.retry(error)) {
6720
+ reject(operation.mainError());
6721
+ }
6722
+ }
6723
+ }
6724
+ });
6725
+ });
6726
+ pRetry.exports = pRetry$1;
6727
+ pRetry.exports.default = pRetry$1;
6728
+ pRetry.exports.AbortError = AbortError;
6729
+ return pRetry.exports;
6606
6730
  }
6607
6731
 
6732
+ var pRetryExports = requirePRetry();
6733
+ var ai = /*@__PURE__*/getDefaultExportFromCjs(pRetryExports);
6734
+
6608
6735
  var Yn = Object.defineProperty;
6609
6736
  var s = (e, t) => Yn(e, "name", { value: t, configurable: true });
6610
6737
  const st = BigInt(2 ** 32 - 1), Ar = BigInt(32);
@@ -9484,9 +9611,9 @@ function Wn({ sensitiveValues: e, step: t }) {
9484
9611
  }
9485
9612
  s(Wn, "extractStep");
9486
9613
  async function La({ fileData: e, maxRetries: t = 3, uploadUrl: r }) {
9487
- await pRetry(async () => {
9614
+ await ai(async () => {
9488
9615
  const n = await fetch(r, { body: e, method: "PUT" });
9489
- if (!n.ok) throw n.status >= 400 && n.status < 500 ? new AbortError(`Upload failed with status ${n.status}: ${n.statusText}`) : new Error(`Upload failed with status ${n.status}: ${n.statusText}`);
9616
+ if (!n.ok) throw n.status >= 400 && n.status < 500 ? new pRetryExports.AbortError(`Upload failed with status ${n.status}: ${n.statusText}`) : new Error(`Upload failed with status ${n.status}: ${n.statusText}`);
9490
9617
  }, { minTimeout: 2e3, randomize: true, retries: t });
9491
9618
  }
9492
9619
  s(La, "uploadWithRetry");
@@ -9674,4 +9801,4 @@ s(xa, "stablyReporter");
9674
9801
 
9675
9802
  exports.Vn = Vn;
9676
9803
  exports.xa = xa;
9677
- //# sourceMappingURL=index-Da3bGLIB.cjs.map
9804
+ //# sourceMappingURL=index-Covr1y-4.cjs.map