@browserless.io/browserless 2.24.2 → 2.24.3

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.
@@ -280,14 +280,14 @@
280
280
  "length": {
281
281
  "type": "number"
282
282
  },
283
- "__@toStringTag@29073": {
283
+ "__@toStringTag@25009": {
284
284
  "type": "string",
285
285
  "const": "Uint8Array"
286
286
  }
287
287
  },
288
288
  "required": [
289
289
  "BYTES_PER_ELEMENT",
290
- "__@toStringTag@29073",
290
+ "__@toStringTag@25009",
291
291
  "buffer",
292
292
  "byteLength",
293
293
  "byteOffset",
@@ -322,13 +322,13 @@
322
322
  "byteLength": {
323
323
  "type": "number"
324
324
  },
325
- "__@toStringTag@29073": {
325
+ "__@toStringTag@25009": {
326
326
  "type": "string"
327
327
  }
328
328
  },
329
329
  "additionalProperties": false,
330
330
  "required": [
331
- "__@toStringTag@29073",
331
+ "__@toStringTag@25009",
332
332
  "byteLength"
333
333
  ]
334
334
  },
@@ -338,18 +338,18 @@
338
338
  "byteLength": {
339
339
  "type": "number"
340
340
  },
341
- "__@species@29111": {
341
+ "__@species@25047": {
342
342
  "$ref": "#/definitions/SharedArrayBuffer"
343
343
  },
344
- "__@toStringTag@29073": {
344
+ "__@toStringTag@25009": {
345
345
  "type": "string",
346
346
  "const": "SharedArrayBuffer"
347
347
  }
348
348
  },
349
349
  "additionalProperties": false,
350
350
  "required": [
351
- "__@species@29111",
352
- "__@toStringTag@29073",
351
+ "__@species@25047",
352
+ "__@toStringTag@25009",
353
353
  "byteLength"
354
354
  ]
355
355
  },
@@ -1001,7 +1001,7 @@
1001
1001
  },
1002
1002
  "info": {
1003
1003
  "title": "Browserless",
1004
- "version": "2.24.2",
1004
+ "version": "2.24.3",
1005
1005
  "x-logo": {
1006
1006
  "altText": "browserless logo",
1007
1007
  "url": "./docs/browserless-logo-inline.svg"
@@ -4393,7 +4393,7 @@
4393
4393
  // node_modules/puppeteer-core/lib/esm/puppeteer/generated/version.js
4394
4394
  init_dirname();
4395
4395
  init_buffer2();
4396
- var packageVersion = "23.11.1";
4396
+ var packageVersion = "24.1.1";
4397
4397
 
4398
4398
  // node_modules/puppeteer-core/lib/esm/puppeteer/util/assert.js
4399
4399
  init_dirname();
@@ -4538,17 +4538,50 @@
4538
4538
  init_dirname();
4539
4539
  init_buffer2();
4540
4540
  var paperFormats = {
4541
- letter: { width: 8.5, height: 11 },
4542
- legal: { width: 8.5, height: 14 },
4543
- tabloid: { width: 11, height: 17 },
4544
- ledger: { width: 17, height: 11 },
4545
- a0: { width: 33.1102, height: 46.811 },
4546
- a1: { width: 23.3858, height: 33.1102 },
4547
- a2: { width: 16.5354, height: 23.3858 },
4548
- a3: { width: 11.6929, height: 16.5354 },
4549
- a4: { width: 8.2677, height: 11.6929 },
4550
- a5: { width: 5.8268, height: 8.2677 },
4551
- a6: { width: 4.1339, height: 5.8268 }
4541
+ letter: {
4542
+ cm: { width: 21.59, height: 27.94 },
4543
+ in: { width: 8.5, height: 11 }
4544
+ },
4545
+ legal: {
4546
+ cm: { width: 21.59, height: 35.56 },
4547
+ in: { width: 8.5, height: 14 }
4548
+ },
4549
+ tabloid: {
4550
+ cm: { width: 27.94, height: 43.18 },
4551
+ in: { width: 11, height: 17 }
4552
+ },
4553
+ ledger: {
4554
+ cm: { width: 43.18, height: 27.94 },
4555
+ in: { width: 17, height: 11 }
4556
+ },
4557
+ a0: {
4558
+ cm: { width: 84.1, height: 118.9 },
4559
+ in: { width: 33.1102, height: 46.811 }
4560
+ },
4561
+ a1: {
4562
+ cm: { width: 59.4, height: 84.1 },
4563
+ in: { width: 23.3858, height: 33.1102 }
4564
+ },
4565
+ a2: {
4566
+ cm: { width: 42, height: 59.4 },
4567
+ in: { width: 16.5354, height: 23.3858 }
4568
+ },
4569
+ a3: {
4570
+ cm: { width: 29.7, height: 42 },
4571
+ in: { width: 11.6929, height: 16.5354 }
4572
+ },
4573
+ a4: {
4574
+ cm: { width: 21, height: 29.7 },
4575
+ in: { width: 8.2677, height: 11.6929 }
4576
+ },
4577
+ a5: {
4578
+ cm: { width: 14.8, height: 21 },
4579
+ in: { width: 5.8268, height: 8.2677 }
4580
+ },
4581
+ a6: {
4582
+ cm: { width: 10.5, height: 14.8 },
4583
+ in: { width: 4.1339, height: 5.8268 }
4584
+ }
4552
4585
  };
4553
4586
 
4554
4587
  // node_modules/puppeteer-core/lib/esm/puppeteer/common/util.js
@@ -4731,7 +4764,7 @@
4731
4764
  let width = 8.5;
4732
4765
  let height = 11;
4733
4766
  if (options.format) {
4734
- const format = paperFormats[options.format.toLowerCase()];
4767
+ const format = paperFormats[options.format.toLowerCase()][lengthUnit];
4735
4768
  assert(format, "Unknown paper format: " + options.format);
4736
4769
  width = format.width;
4737
4770
  height = format.height;
@@ -9626,136 +9659,6 @@
9626
9659
  };
9627
9660
  })();
9628
9661
 
9629
- // node_modules/puppeteer-core/lib/esm/puppeteer/cdp/FirefoxTargetManager.js
9630
- init_dirname();
9631
- init_buffer2();
9632
- var FirefoxTargetManager = class extends EventEmitter {
9633
- #connection;
9634
- /**
9635
- * Keeps track of the following events: 'Target.targetCreated',
9636
- * 'Target.targetDestroyed'.
9637
- *
9638
- * A target becomes discovered when 'Target.targetCreated' is received.
9639
- * A target is removed from this map once 'Target.targetDestroyed' is
9640
- * received.
9641
- *
9642
- * `targetFilterCallback` has no effect on this map.
9643
- */
9644
- #discoveredTargetsByTargetId = /* @__PURE__ */ new Map();
9645
- /**
9646
- * Keeps track of targets that were created via 'Target.targetCreated'
9647
- * and which one are not filtered out by `targetFilterCallback`.
9648
- *
9649
- * The target is removed from here once it's been destroyed.
9650
- */
9651
- #availableTargetsByTargetId = /* @__PURE__ */ new Map();
9652
- /**
9653
- * Tracks which sessions attach to which target.
9654
- */
9655
- #availableTargetsBySessionId = /* @__PURE__ */ new Map();
9656
- #targetFilterCallback;
9657
- #targetFactory;
9658
- #attachedToTargetListenersBySession = /* @__PURE__ */ new WeakMap();
9659
- #initializeDeferred = Deferred.create();
9660
- #targetsIdsForInit = /* @__PURE__ */ new Set();
9661
- constructor(connection, targetFactory, targetFilterCallback) {
9662
- super();
9663
- this.#connection = connection;
9664
- this.#targetFilterCallback = targetFilterCallback;
9665
- this.#targetFactory = targetFactory;
9666
- this.#connection.on("Target.targetCreated", this.#onTargetCreated);
9667
- this.#connection.on("Target.targetDestroyed", this.#onTargetDestroyed);
9668
- this.#connection.on(CDPSessionEvent.SessionDetached, this.#onSessionDetached);
9669
- this.setupAttachmentListeners(this.#connection);
9670
- }
9671
- setupAttachmentListeners(session) {
9672
- const listener = (event) => {
9673
- return this.#onAttachedToTarget(session, event);
9674
- };
9675
- assert(!this.#attachedToTargetListenersBySession.has(session));
9676
- this.#attachedToTargetListenersBySession.set(session, listener);
9677
- session.on("Target.attachedToTarget", listener);
9678
- }
9679
- #onSessionDetached = (session) => {
9680
- this.removeSessionListeners(session);
9681
- this.#availableTargetsBySessionId.delete(session.id());
9682
- };
9683
- removeSessionListeners(session) {
9684
- if (this.#attachedToTargetListenersBySession.has(session)) {
9685
- session.off("Target.attachedToTarget", this.#attachedToTargetListenersBySession.get(session));
9686
- this.#attachedToTargetListenersBySession.delete(session);
9687
- }
9688
- }
9689
- getAvailableTargets() {
9690
- return this.#availableTargetsByTargetId;
9691
- }
9692
- getChildTargets(_target) {
9693
- return /* @__PURE__ */ new Set();
9694
- }
9695
- dispose() {
9696
- this.#connection.off("Target.targetCreated", this.#onTargetCreated);
9697
- this.#connection.off("Target.targetDestroyed", this.#onTargetDestroyed);
9698
- }
9699
- async initialize() {
9700
- await this.#connection.send("Target.setDiscoverTargets", {
9701
- discover: true,
9702
- filter: [{}]
9703
- });
9704
- this.#targetsIdsForInit = new Set(this.#discoveredTargetsByTargetId.keys());
9705
- await this.#initializeDeferred.valueOrThrow();
9706
- }
9707
- #onTargetCreated = async (event) => {
9708
- if (this.#discoveredTargetsByTargetId.has(event.targetInfo.targetId)) {
9709
- return;
9710
- }
9711
- this.#discoveredTargetsByTargetId.set(event.targetInfo.targetId, event.targetInfo);
9712
- if (event.targetInfo.type === "browser" && event.targetInfo.attached) {
9713
- const target2 = this.#targetFactory(event.targetInfo, void 0);
9714
- target2._initialize();
9715
- this.#availableTargetsByTargetId.set(event.targetInfo.targetId, target2);
9716
- this.#finishInitializationIfReady(target2._targetId);
9717
- return;
9718
- }
9719
- const target = this.#targetFactory(event.targetInfo, void 0);
9720
- if (this.#targetFilterCallback && !this.#targetFilterCallback(target)) {
9721
- this.#finishInitializationIfReady(event.targetInfo.targetId);
9722
- return;
9723
- }
9724
- target._initialize();
9725
- this.#availableTargetsByTargetId.set(event.targetInfo.targetId, target);
9726
- this.emit("targetAvailable", target);
9727
- this.#finishInitializationIfReady(target._targetId);
9728
- };
9729
- #onTargetDestroyed = (event) => {
9730
- this.#discoveredTargetsByTargetId.delete(event.targetId);
9731
- this.#finishInitializationIfReady(event.targetId);
9732
- const target = this.#availableTargetsByTargetId.get(event.targetId);
9733
- if (target) {
9734
- this.emit("targetGone", target);
9735
- this.#availableTargetsByTargetId.delete(event.targetId);
9736
- }
9737
- };
9738
- #onAttachedToTarget = async (parentSession, event) => {
9739
- const targetInfo = event.targetInfo;
9740
- const session = this.#connection.session(event.sessionId);
9741
- if (!session) {
9742
- throw new Error(`Session ${event.sessionId} was not created.`);
9743
- }
9744
- const target = this.#availableTargetsByTargetId.get(targetInfo.targetId);
9745
- assert(target, `Target ${targetInfo.targetId} is missing`);
9746
- session._setTarget(target);
9747
- this.setupAttachmentListeners(session);
9748
- this.#availableTargetsBySessionId.set(session.id(), this.#availableTargetsByTargetId.get(targetInfo.targetId));
9749
- parentSession.emit(CDPSessionEvent.Ready, session);
9750
- };
9751
- #finishInitializationIfReady(targetId) {
9752
- this.#targetsIdsForInit.delete(targetId);
9753
- if (this.#targetsIdsForInit.size === 0) {
9754
- this.#initializeDeferred.resolve();
9755
- }
9756
- }
9757
- };
9758
-
9759
9662
  // node_modules/puppeteer-core/lib/esm/puppeteer/cdp/FrameManager.js
9760
9663
  init_dirname();
9761
9664
  init_buffer2();
@@ -12103,8 +12006,8 @@
12103
12006
  /**
12104
12007
  * @internal
12105
12008
  */
12106
- dispose() {
12107
- return this.handle.dispose();
12009
+ async dispose() {
12010
+ await Promise.all([this.handle.dispose(), this.isolatedHandle?.dispose()]);
12108
12011
  }
12109
12012
  /**
12110
12013
  * @internal
@@ -14482,7 +14385,7 @@ ${sourceUrlComment}
14482
14385
  }
14483
14386
  if (this.#poller) {
14484
14387
  try {
14485
- await this.#poller.evaluateHandle(async (poller) => {
14388
+ await this.#poller.evaluate(async (poller) => {
14486
14389
  await poller.stop();
14487
14390
  });
14488
14391
  if (this.#poller) {
@@ -14507,7 +14410,7 @@ ${sourceUrlComment}
14507
14410
  if (error.message.includes("Cannot find context with specified id")) {
14508
14411
  return;
14509
14412
  }
14510
- if (error.message.includes("AbortError: Actor 'MessageHandlerFrame' destroyed")) {
14413
+ if (error.message.includes("DiscardedBrowsingContextError")) {
14511
14414
  return;
14512
14415
  }
14513
14416
  return error;
@@ -15161,10 +15064,6 @@ ${sourceUrlComment}
15161
15064
  throw new UnsupportedOperation();
15162
15065
  }
15163
15066
  async frameElement() {
15164
- const isFirefox = this.page().target()._targetManager() instanceof FirefoxTargetManager;
15165
- if (isFirefox) {
15166
- return await super.frameElement();
15167
- }
15168
15067
  const parent = this.parentFrame();
15169
15068
  if (!parent) {
15170
15069
  return null;
@@ -15680,7 +15579,7 @@ ${sourceUrlComment}
15680
15579
  this.id = data.requestId;
15681
15580
  this.#isNavigationRequest = data.requestId === data.loaderId && data.type === "Document";
15682
15581
  this._interceptionId = interceptionId;
15683
- this.#url = data.request.url;
15582
+ this.#url = data.request.url + (data.request.urlFragment ?? "");
15684
15583
  this.#resourceType = (data.type || "other").toLowerCase();
15685
15584
  this.#method = data.request.method;
15686
15585
  this.#postData = data.request.postData;
@@ -15931,7 +15830,6 @@ ${sourceUrlComment}
15931
15830
  #remoteAddress;
15932
15831
  #status;
15933
15832
  #statusText;
15934
- #url;
15935
15833
  #fromDiskCache;
15936
15834
  #fromServiceWorker;
15937
15835
  #headers = {};
@@ -15945,7 +15843,6 @@ ${sourceUrlComment}
15945
15843
  port: responsePayload.remotePort
15946
15844
  };
15947
15845
  this.#statusText = this.#parseStatusTextFromExtraInfo(extraInfo) || responsePayload.statusText;
15948
- this.#url = request.url();
15949
15846
  this.#fromDiskCache = !!responsePayload.fromDiskCache;
15950
15847
  this.#fromServiceWorker = !!responsePayload.fromServiceWorker;
15951
15848
  this.#status = extraInfo ? extraInfo.statusCode : responsePayload.status;
@@ -15984,7 +15881,7 @@ ${sourceUrlComment}
15984
15881
  return this.#remoteAddress;
15985
15882
  }
15986
15883
  url() {
15987
- return this.#url;
15884
+ return this.#request.url();
15988
15885
  }
15989
15886
  status() {
15990
15887
  return this.#status;
@@ -18883,9 +18780,8 @@ ${sourceUrlComment}
18883
18780
  const env_2 = { stack: [], error: void 0, hasError: false };
18884
18781
  try {
18885
18782
  const { fromSurface, omitBackground, optimizeForSpeed, quality, clip: userClip, type, captureBeyondViewport } = options;
18886
- const isFirefox = this.target()._targetManager() instanceof FirefoxTargetManager;
18887
18783
  const stack = __addDisposableResource12(env_2, new AsyncDisposableStack(), true);
18888
- if (!isFirefox && omitBackground && (type === "png" || type === "webp")) {
18784
+ if (omitBackground && (type === "png" || type === "webp")) {
18889
18785
  await this.#emulationManager.setTransparentBackgroundColor();
18890
18786
  stack.defer(async () => {
18891
18787
  await this.#emulationManager.resetDefaultBackgroundColor().catch(debugError);
@@ -18901,10 +18797,10 @@ ${sourceUrlComment}
18901
18797
  }
18902
18798
  const { data } = await this.#primaryTargetClient.send("Page.captureScreenshot", {
18903
18799
  format: type,
18904
- ...optimizeForSpeed ? { optimizeForSpeed } : {},
18800
+ optimizeForSpeed,
18801
+ fromSurface,
18905
18802
  ...quality !== void 0 ? { quality: Math.round(quality) } : {},
18906
18803
  ...clip ? { clip: { ...clip, scale: clip.scale ?? 1 } } : {},
18907
- ...!fromSurface ? { fromSurface } : {},
18908
18804
  captureBeyondViewport
18909
18805
  });
18910
18806
  return data;
@@ -19216,10 +19112,6 @@ ${sourceUrlComment}
19216
19112
  }
19217
19113
  };
19218
19114
 
19219
- // node_modules/puppeteer-core/lib/esm/puppeteer/cdp/ChromeTargetManager.js
19220
- init_dirname();
19221
- init_buffer2();
19222
-
19223
19115
  // node_modules/puppeteer-core/lib/esm/puppeteer/cdp/Target.js
19224
19116
  init_dirname();
19225
19117
  init_buffer2();
@@ -19447,11 +19339,13 @@ ${sourceUrlComment}
19447
19339
  var OtherTarget = class extends CdpTarget {
19448
19340
  };
19449
19341
 
19450
- // node_modules/puppeteer-core/lib/esm/puppeteer/cdp/ChromeTargetManager.js
19342
+ // node_modules/puppeteer-core/lib/esm/puppeteer/cdp/TargetManager.js
19343
+ init_dirname();
19344
+ init_buffer2();
19451
19345
  function isPageTargetBecomingPrimary(target, newTargetInfo) {
19452
19346
  return Boolean(target._subtype()) && !newTargetInfo.subtype;
19453
19347
  }
19454
- var ChromeTargetManager = class extends EventEmitter {
19348
+ var TargetManager = class extends EventEmitter {
19455
19349
  #connection;
19456
19350
  /**
19457
19351
  * Keeps track of the following events: 'Target.targetCreated',
@@ -19465,7 +19359,7 @@ ${sourceUrlComment}
19465
19359
  */
19466
19360
  #discoveredTargetsByTargetId = /* @__PURE__ */ new Map();
19467
19361
  /**
19468
- * A target is added to this map once ChromeTargetManager has created
19362
+ * A target is added to this map once TargetManager has created
19469
19363
  * a Target and attached at least once to it.
19470
19364
  */
19471
19365
  #attachedTargetsByTargetId = /* @__PURE__ */ new Map();
@@ -19709,8 +19603,8 @@ ${sourceUrlComment}
19709
19603
  // node_modules/puppeteer-core/lib/esm/puppeteer/cdp/Browser.js
19710
19604
  var CdpBrowser = class _CdpBrowser extends Browser {
19711
19605
  protocol = "cdp";
19712
- static async _create(product, connection, contextIds, acceptInsecureCerts, defaultViewport, downloadBehavior, process3, closeCallback, targetFilterCallback, isPageTargetCallback, waitForInitiallyDiscoveredTargets = true) {
19713
- const browser = new _CdpBrowser(product, connection, contextIds, defaultViewport, process3, closeCallback, targetFilterCallback, isPageTargetCallback, waitForInitiallyDiscoveredTargets);
19606
+ static async _create(connection, contextIds, acceptInsecureCerts, defaultViewport, downloadBehavior, process3, closeCallback, targetFilterCallback, isPageTargetCallback, waitForInitiallyDiscoveredTargets = true) {
19607
+ const browser = new _CdpBrowser(connection, contextIds, defaultViewport, process3, closeCallback, targetFilterCallback, isPageTargetCallback, waitForInitiallyDiscoveredTargets);
19714
19608
  if (acceptInsecureCerts) {
19715
19609
  await connection.send("Security.setIgnoreCertificateErrors", {
19716
19610
  ignore: true
@@ -19728,9 +19622,8 @@ ${sourceUrlComment}
19728
19622
  #defaultContext;
19729
19623
  #contexts = /* @__PURE__ */ new Map();
19730
19624
  #targetManager;
19731
- constructor(product, connection, contextIds, defaultViewport, process3, closeCallback, targetFilterCallback, isPageTargetCallback, waitForInitiallyDiscoveredTargets = true) {
19625
+ constructor(connection, contextIds, defaultViewport, process3, closeCallback, targetFilterCallback, isPageTargetCallback, waitForInitiallyDiscoveredTargets = true) {
19732
19626
  super();
19733
- product = product || "chrome";
19734
19627
  this.#defaultViewport = defaultViewport;
19735
19628
  this.#process = process3;
19736
19629
  this.#connection = connection;
@@ -19740,11 +19633,7 @@ ${sourceUrlComment}
19740
19633
  return true;
19741
19634
  });
19742
19635
  this.#setIsPageTargetCallback(isPageTargetCallback);
19743
- if (product === "firefox") {
19744
- this.#targetManager = new FirefoxTargetManager(connection, this.#createTarget, this.#targetFilterCallback);
19745
- } else {
19746
- this.#targetManager = new ChromeTargetManager(connection, this.#createTarget, this.#targetFilterCallback, waitForInitiallyDiscoveredTargets);
19747
- }
19636
+ this.#targetManager = new TargetManager(connection, this.#createTarget, this.#targetFilterCallback, waitForInitiallyDiscoveredTargets);
19748
19637
  this.#defaultContext = new CdpBrowserContext(this.#connection, this);
19749
19638
  for (const contextId of contextIds) {
19750
19639
  this.#contexts.set(contextId, new CdpBrowserContext(this.#connection, this, contextId));
@@ -19931,10 +19820,8 @@ ${sourceUrlComment}
19931
19820
  async function _connectToCdpBrowser(connectionTransport, url, options) {
19932
19821
  const { acceptInsecureCerts = false, defaultViewport = DEFAULT_VIEWPORT, downloadBehavior, targetFilter, _isPageTarget: isPageTarget, slowMo = 0, protocolTimeout } = options;
19933
19822
  const connection = new Connection(url, connectionTransport, slowMo, protocolTimeout);
19934
- const version = await connection.send("Browser.getVersion");
19935
- const product = version.product.toLowerCase().includes("firefox") ? "firefox" : "chrome";
19936
19823
  const { browserContextIds } = await connection.send("Target.getBrowserContexts");
19937
- const browser = await CdpBrowser._create(product || "chrome", connection, browserContextIds, acceptInsecureCerts, defaultViewport, downloadBehavior, void 0, () => {
19824
+ const browser = await CdpBrowser._create(connection, browserContextIds, acceptInsecureCerts, defaultViewport, downloadBehavior, void 0, () => {
19938
19825
  return connection.send("Browser.close").catch(debugError);
19939
19826
  }, targetFilter, isPageTarget);
19940
19827
  return browser;
@@ -20217,13 +20104,6 @@ puppeteer-core/lib/esm/puppeteer/cdp/Dialog.js:
20217
20104
  * SPDX-License-Identifier: Apache-2.0
20218
20105
  *)
20219
20106
 
20220
- puppeteer-core/lib/esm/puppeteer/cdp/FirefoxTargetManager.js:
20221
- (**
20222
- * @license
20223
- * Copyright 2022 Google Inc.
20224
- * SPDX-License-Identifier: Apache-2.0
20225
- *)
20226
-
20227
20107
  puppeteer-core/lib/esm/puppeteer/api/ElementHandleSymbol.js:
20228
20108
  (**
20229
20109
  * @license
@@ -20539,7 +20419,7 @@ puppeteer-core/lib/esm/puppeteer/cdp/Target.js:
20539
20419
  * SPDX-License-Identifier: Apache-2.0
20540
20420
  *)
20541
20421
 
20542
- puppeteer-core/lib/esm/puppeteer/cdp/ChromeTargetManager.js:
20422
+ puppeteer-core/lib/esm/puppeteer/cdp/TargetManager.js:
20543
20423
  (**
20544
20424
  * @license
20545
20425
  * Copyright 2022 Google Inc.