@browserless.io/browserless 2.24.0-beta-5 → 2.24.1

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 (79) hide show
  1. package/CHANGELOG.md +22 -1
  2. package/bin/browserless.js +1 -1
  3. package/build/browsers/browsers.playwright.d.ts +1 -0
  4. package/build/browsers/browsers.playwright.js +3 -0
  5. package/build/browsers/index.d.ts +2 -1
  6. package/build/browsers/index.js +28 -7
  7. package/build/http.d.ts +5 -0
  8. package/build/http.js +1 -0
  9. package/build/routes/chrome/http/content.post.body.json +8 -8
  10. package/build/routes/chrome/http/content.post.query.json +4 -0
  11. package/build/routes/chrome/http/download.post.query.json +4 -0
  12. package/build/routes/chrome/http/function.post.query.json +4 -0
  13. package/build/routes/chrome/http/pdf.post.body.json +8 -8
  14. package/build/routes/chrome/http/pdf.post.query.json +4 -0
  15. package/build/routes/chrome/http/performance.post.query.json +4 -0
  16. package/build/routes/chrome/http/scrape.post.body.json +8 -8
  17. package/build/routes/chrome/http/scrape.post.query.json +4 -0
  18. package/build/routes/chrome/http/screenshot.post.body.json +8 -8
  19. package/build/routes/chrome/http/screenshot.post.query.json +4 -0
  20. package/build/routes/chrome/tests/kill-sessions.spec.d.ts +1 -0
  21. package/build/routes/chrome/tests/kill-sessions.spec.js +80 -0
  22. package/build/routes/chrome/ws/browser.query.json +4 -0
  23. package/build/routes/chrome/ws/cdp.query.json +4 -0
  24. package/build/routes/chrome/ws/page.query.json +4 -0
  25. package/build/routes/chrome/ws/playwright.query.json +4 -0
  26. package/build/routes/chromium/http/content.post.body.json +8 -8
  27. package/build/routes/chromium/http/content.post.query.json +4 -0
  28. package/build/routes/chromium/http/download.post.query.json +4 -0
  29. package/build/routes/chromium/http/function.post.query.json +4 -0
  30. package/build/routes/chromium/http/pdf.post.body.json +8 -8
  31. package/build/routes/chromium/http/pdf.post.query.json +4 -0
  32. package/build/routes/chromium/http/performance.post.query.json +4 -0
  33. package/build/routes/chromium/http/scrape.post.body.json +8 -8
  34. package/build/routes/chromium/http/scrape.post.query.json +4 -0
  35. package/build/routes/chromium/http/screenshot.post.body.json +8 -8
  36. package/build/routes/chromium/http/screenshot.post.query.json +4 -0
  37. package/build/routes/chromium/tests/kill-sessions.spec.d.ts +1 -0
  38. package/build/routes/chromium/tests/kill-sessions.spec.js +80 -0
  39. package/build/routes/chromium/tests/websocket.spec.js +23 -0
  40. package/build/routes/chromium/ws/browser.query.json +4 -0
  41. package/build/routes/chromium/ws/cdp.query.json +4 -0
  42. package/build/routes/chromium/ws/page.query.json +4 -0
  43. package/build/routes/chromium/ws/playwright.query.json +4 -0
  44. package/build/routes/firefox/tests/kill-sessions.spec.d.ts +1 -0
  45. package/build/routes/firefox/tests/kill-sessions.spec.js +72 -0
  46. package/build/routes/firefox/ws/playwright.query.json +4 -0
  47. package/build/routes/management/http/kill.get.d.ts +21 -0
  48. package/build/routes/management/http/kill.get.js +19 -0
  49. package/build/routes/management/http/kill.get.query.json +193 -0
  50. package/build/routes/management/http/meta.get.js +3 -2
  51. package/build/routes/management/http/sessions.get.query.json +1 -0
  52. package/build/routes/management/tests/management.spec.js +12 -0
  53. package/build/routes/webkit/tests/kill-sessions.spec.d.ts +1 -0
  54. package/build/routes/webkit/tests/kill-sessions.spec.js +72 -0
  55. package/build/routes/webkit/ws/playwright.query.json +4 -0
  56. package/build/shared/utils/performance/main.js +2 -1
  57. package/build/types.d.ts +2 -0
  58. package/build/types.js +1 -0
  59. package/build/utils.d.ts +1 -1
  60. package/build/utils.js +1 -10
  61. package/package.json +13 -13
  62. package/src/browsers/browsers.playwright.ts +3 -0
  63. package/src/browsers/index.ts +33 -12
  64. package/src/http.ts +6 -0
  65. package/src/routes/chrome/tests/kill-sessions.spec.ts +99 -0
  66. package/src/routes/chromium/tests/kill-sessions.spec.ts +99 -0
  67. package/src/routes/chromium/tests/websocket.spec.ts +29 -0
  68. package/src/routes/firefox/tests/kill-sessions.spec.ts +99 -0
  69. package/src/routes/management/http/kill.get.ts +40 -0
  70. package/src/routes/management/http/meta.get.ts +12 -10
  71. package/src/routes/management/tests/management.spec.ts +19 -0
  72. package/src/routes/webkit/tests/kill-sessions.spec.ts +99 -0
  73. package/src/shared/utils/performance/main.ts +2 -8
  74. package/src/types.ts +1 -0
  75. package/src/utils.ts +2 -11
  76. package/static/docs/swagger.json +297 -10
  77. package/static/docs/swagger.min.json +296 -9
  78. package/static/function/client.js +157 -42
  79. package/static/function/index.html +157 -42
@@ -1998,50 +1998,64 @@
1998
1998
  createDebug.namespaces = namespaces;
1999
1999
  createDebug.names = [];
2000
2000
  createDebug.skips = [];
2001
- let i;
2002
- const split = (typeof namespaces === "string" ? namespaces : "").split(/[\s,]+/);
2003
- const len = split.length;
2004
- for (i = 0; i < len; i++) {
2005
- if (!split[i]) {
2006
- continue;
2001
+ const split = (typeof namespaces === "string" ? namespaces : "").trim().replace(" ", ",").split(",").filter(Boolean);
2002
+ for (const ns of split) {
2003
+ if (ns[0] === "-") {
2004
+ createDebug.skips.push(ns.slice(1));
2005
+ } else {
2006
+ createDebug.names.push(ns);
2007
2007
  }
2008
- namespaces = split[i].replace(/\*/g, ".*?");
2009
- if (namespaces[0] === "-") {
2010
- createDebug.skips.push(new RegExp("^" + namespaces.slice(1) + "$"));
2008
+ }
2009
+ }
2010
+ function matchesTemplate(search, template) {
2011
+ let searchIndex = 0;
2012
+ let templateIndex = 0;
2013
+ let starIndex = -1;
2014
+ let matchIndex = 0;
2015
+ while (searchIndex < search.length) {
2016
+ if (templateIndex < template.length && (template[templateIndex] === search[searchIndex] || template[templateIndex] === "*")) {
2017
+ if (template[templateIndex] === "*") {
2018
+ starIndex = templateIndex;
2019
+ matchIndex = searchIndex;
2020
+ templateIndex++;
2021
+ } else {
2022
+ searchIndex++;
2023
+ templateIndex++;
2024
+ }
2025
+ } else if (starIndex !== -1) {
2026
+ templateIndex = starIndex + 1;
2027
+ matchIndex++;
2028
+ searchIndex = matchIndex;
2011
2029
  } else {
2012
- createDebug.names.push(new RegExp("^" + namespaces + "$"));
2030
+ return false;
2013
2031
  }
2014
2032
  }
2033
+ while (templateIndex < template.length && template[templateIndex] === "*") {
2034
+ templateIndex++;
2035
+ }
2036
+ return templateIndex === template.length;
2015
2037
  }
2016
2038
  function disable() {
2017
2039
  const namespaces = [
2018
- ...createDebug.names.map(toNamespace),
2019
- ...createDebug.skips.map(toNamespace).map((namespace) => "-" + namespace)
2040
+ ...createDebug.names,
2041
+ ...createDebug.skips.map((namespace) => "-" + namespace)
2020
2042
  ].join(",");
2021
2043
  createDebug.enable("");
2022
2044
  return namespaces;
2023
2045
  }
2024
2046
  function enabled(name) {
2025
- if (name[name.length - 1] === "*") {
2026
- return true;
2027
- }
2028
- let i;
2029
- let len;
2030
- for (i = 0, len = createDebug.skips.length; i < len; i++) {
2031
- if (createDebug.skips[i].test(name)) {
2047
+ for (const skip of createDebug.skips) {
2048
+ if (matchesTemplate(name, skip)) {
2032
2049
  return false;
2033
2050
  }
2034
2051
  }
2035
- for (i = 0, len = createDebug.names.length; i < len; i++) {
2036
- if (createDebug.names[i].test(name)) {
2052
+ for (const ns of createDebug.names) {
2053
+ if (matchesTemplate(name, ns)) {
2037
2054
  return true;
2038
2055
  }
2039
2056
  }
2040
2057
  return false;
2041
2058
  }
2042
- function toNamespace(regexp) {
2043
- return regexp.toString().substring(2, regexp.toString().length - 2).replace(/\.\*\?$/, "*");
2044
- }
2045
2059
  function coerce(val) {
2046
2060
  if (val instanceof Error) {
2047
2061
  return val.stack || val.message;
@@ -4379,7 +4393,7 @@
4379
4393
  // node_modules/puppeteer-core/lib/esm/puppeteer/generated/version.js
4380
4394
  init_dirname();
4381
4395
  init_buffer2();
4382
- var packageVersion = "23.10.0";
4396
+ var packageVersion = "23.11.1";
4383
4397
 
4384
4398
  // node_modules/puppeteer-core/lib/esm/puppeteer/util/assert.js
4385
4399
  init_dirname();
@@ -9512,6 +9526,7 @@
9512
9526
  "blurredVision",
9513
9527
  "deuteranopia",
9514
9528
  "protanopia",
9529
+ "reducedContrast",
9515
9530
  "tritanopia"
9516
9531
  ]);
9517
9532
  assert(!type || visionDeficiencies.has(type), `Unsupported vision deficiency: ${type}`);
@@ -13861,13 +13876,73 @@ ${sourceUrlComment}
13861
13876
  // node_modules/puppeteer-core/lib/esm/puppeteer/cdp/Accessibility.js
13862
13877
  init_dirname();
13863
13878
  init_buffer2();
13879
+ var __addDisposableResource11 = function(env, value, async2) {
13880
+ if (value !== null && value !== void 0) {
13881
+ if (typeof value !== "object" && typeof value !== "function") throw new TypeError("Object expected.");
13882
+ var dispose, inner;
13883
+ if (async2) {
13884
+ if (!Symbol.asyncDispose) throw new TypeError("Symbol.asyncDispose is not defined.");
13885
+ dispose = value[Symbol.asyncDispose];
13886
+ }
13887
+ if (dispose === void 0) {
13888
+ if (!Symbol.dispose) throw new TypeError("Symbol.dispose is not defined.");
13889
+ dispose = value[Symbol.dispose];
13890
+ if (async2) inner = dispose;
13891
+ }
13892
+ if (typeof dispose !== "function") throw new TypeError("Object not disposable.");
13893
+ if (inner) dispose = function() {
13894
+ try {
13895
+ inner.call(this);
13896
+ } catch (e) {
13897
+ return Promise.reject(e);
13898
+ }
13899
+ };
13900
+ env.stack.push({ value, dispose, async: async2 });
13901
+ } else if (async2) {
13902
+ env.stack.push({ async: true });
13903
+ }
13904
+ return value;
13905
+ };
13906
+ var __disposeResources11 = /* @__PURE__ */ function(SuppressedError2) {
13907
+ return function(env) {
13908
+ function fail(e) {
13909
+ env.error = env.hasError ? new SuppressedError2(e, env.error, "An error was suppressed during disposal.") : e;
13910
+ env.hasError = true;
13911
+ }
13912
+ var r, s = 0;
13913
+ function next() {
13914
+ while (r = env.stack.pop()) {
13915
+ try {
13916
+ if (!r.async && s === 1) return s = 0, env.stack.push(r), Promise.resolve().then(next);
13917
+ if (r.dispose) {
13918
+ var result = r.dispose.call(r.value);
13919
+ if (r.async) return s |= 2, Promise.resolve(result).then(next, function(e) {
13920
+ fail(e);
13921
+ return next();
13922
+ });
13923
+ } else s |= 1;
13924
+ } catch (e) {
13925
+ fail(e);
13926
+ }
13927
+ }
13928
+ if (s === 1) return env.hasError ? Promise.reject(env.error) : Promise.resolve();
13929
+ if (env.hasError) throw env.error;
13930
+ }
13931
+ return next();
13932
+ };
13933
+ }(typeof SuppressedError === "function" ? SuppressedError : function(error, suppressed, message) {
13934
+ var e = new Error(message);
13935
+ return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
13936
+ });
13864
13937
  var Accessibility = class {
13865
13938
  #realm;
13939
+ #frameId;
13866
13940
  /**
13867
13941
  * @internal
13868
13942
  */
13869
- constructor(realm) {
13943
+ constructor(realm, frameId = "") {
13870
13944
  this.#realm = realm;
13945
+ this.#frameId = frameId;
13871
13946
  }
13872
13947
  /**
13873
13948
  * Captures the current state of the accessibility tree.
@@ -13909,8 +13984,10 @@ ${sourceUrlComment}
13909
13984
  * @returns An AXNode object representing the snapshot.
13910
13985
  */
13911
13986
  async snapshot(options = {}) {
13912
- const { interestingOnly = true, root = null } = options;
13913
- const { nodes } = await this.#realm.environment.client.send("Accessibility.getFullAXTree");
13987
+ const { interestingOnly = true, root = null, includeIframes = false } = options;
13988
+ const { nodes } = await this.#realm.environment.client.send("Accessibility.getFullAXTree", {
13989
+ frameId: this.#frameId
13990
+ });
13914
13991
  let backendNodeId;
13915
13992
  if (root) {
13916
13993
  const { node } = await this.#realm.environment.client.send("DOM.describeNode", {
@@ -13919,10 +13996,41 @@ ${sourceUrlComment}
13919
13996
  backendNodeId = node.backendNodeId;
13920
13997
  }
13921
13998
  const defaultRoot = AXNode.createTree(this.#realm, nodes);
13999
+ const populateIframes = async (root2) => {
14000
+ if (root2.payload.role?.value === "Iframe") {
14001
+ const env_1 = { stack: [], error: void 0, hasError: false };
14002
+ try {
14003
+ if (!root2.payload.backendDOMNodeId) {
14004
+ return;
14005
+ }
14006
+ const handle = __addDisposableResource11(env_1, await this.#realm.adoptBackendNode(root2.payload.backendDOMNodeId), false);
14007
+ if (!handle || !("contentFrame" in handle)) {
14008
+ return;
14009
+ }
14010
+ const frame = await handle.contentFrame();
14011
+ if (!frame) {
14012
+ return;
14013
+ }
14014
+ const iframeSnapshot = await frame.accessibility.snapshot(options);
14015
+ root2.iframeSnapshot = iframeSnapshot ?? void 0;
14016
+ } catch (e_1) {
14017
+ env_1.error = e_1;
14018
+ env_1.hasError = true;
14019
+ } finally {
14020
+ __disposeResources11(env_1);
14021
+ }
14022
+ }
14023
+ for (const child of root2.children) {
14024
+ await populateIframes(child);
14025
+ }
14026
+ };
13922
14027
  let needle = defaultRoot;
13923
14028
  if (!defaultRoot) {
13924
14029
  return null;
13925
14030
  }
14031
+ if (includeIframes) {
14032
+ await populateIframes(defaultRoot);
14033
+ }
13926
14034
  if (backendNodeId) {
13927
14035
  needle = defaultRoot.find((node) => {
13928
14036
  return node.payload.backendDOMNodeId === backendNodeId;
@@ -13953,10 +14061,16 @@ ${sourceUrlComment}
13953
14061
  if (children.length) {
13954
14062
  serializedNode.children = children;
13955
14063
  }
14064
+ if (node.iframeSnapshot) {
14065
+ if (!serializedNode.children) {
14066
+ serializedNode.children = [];
14067
+ }
14068
+ serializedNode.children.push(node.iframeSnapshot);
14069
+ }
13956
14070
  return [serializedNode];
13957
14071
  }
13958
14072
  collectInterestingNodes(collection, node, insideControl) {
13959
- if (node.isInteresting(insideControl)) {
14073
+ if (node.isInteresting(insideControl) || node.iframeSnapshot) {
13960
14074
  collection.add(node);
13961
14075
  }
13962
14076
  if (node.isLeafNode()) {
@@ -13971,6 +14085,7 @@ ${sourceUrlComment}
13971
14085
  var AXNode = class _AXNode {
13972
14086
  payload;
13973
14087
  children = [];
14088
+ iframeSnapshot;
13974
14089
  #richlyEditable = false;
13975
14090
  #editable = false;
13976
14091
  #focusable = false;
@@ -14831,7 +14946,7 @@ ${sourceUrlComment}
14831
14946
  [MAIN_WORLD]: new IsolatedWorld(this, this._frameManager.timeoutSettings),
14832
14947
  [PUPPETEER_WORLD]: new IsolatedWorld(this, this._frameManager.timeoutSettings)
14833
14948
  };
14834
- this.accessibility = new Accessibility(this.worlds[MAIN_WORLD]);
14949
+ this.accessibility = new Accessibility(this.worlds[MAIN_WORLD], frameId);
14835
14950
  this.on(FrameEvent.FrameSwappedByActivation, () => {
14836
14951
  this._onLoadingStarted();
14837
14952
  this._onLoadingStopped();
@@ -18081,7 +18196,7 @@ ${sourceUrlComment}
18081
18196
  };
18082
18197
 
18083
18198
  // node_modules/puppeteer-core/lib/esm/puppeteer/cdp/Page.js
18084
- var __addDisposableResource11 = function(env, value, async2) {
18199
+ var __addDisposableResource12 = function(env, value, async2) {
18085
18200
  if (value !== null && value !== void 0) {
18086
18201
  if (typeof value !== "object" && typeof value !== "function") throw new TypeError("Object expected.");
18087
18202
  var dispose, inner;
@@ -18108,7 +18223,7 @@ ${sourceUrlComment}
18108
18223
  }
18109
18224
  return value;
18110
18225
  };
18111
- var __disposeResources11 = /* @__PURE__ */ function(SuppressedError2) {
18226
+ var __disposeResources12 = /* @__PURE__ */ function(SuppressedError2) {
18112
18227
  return function(env) {
18113
18228
  function fail(e) {
18114
18229
  env.error = env.hasError ? new SuppressedError2(e, env.error, "An error was suppressed during disposal.") : e;
@@ -18350,7 +18465,7 @@ ${sourceUrlComment}
18350
18465
  }
18351
18466
  const frame = this.#frameManager.frame(event.frameId);
18352
18467
  assert(frame, "This should never happen.");
18353
- const handle = __addDisposableResource11(env_1, await frame.worlds[MAIN_WORLD].adoptBackendNode(event.backendNodeId), false);
18468
+ const handle = __addDisposableResource12(env_1, await frame.worlds[MAIN_WORLD].adoptBackendNode(event.backendNodeId), false);
18354
18469
  const fileChooser = new FileChooser(handle.move(), event);
18355
18470
  for (const promise of this.#fileChooserDeferreds) {
18356
18471
  promise.resolve(fileChooser);
@@ -18360,7 +18475,7 @@ ${sourceUrlComment}
18360
18475
  env_1.error = e_1;
18361
18476
  env_1.hasError = true;
18362
18477
  } finally {
18363
- __disposeResources11(env_1);
18478
+ __disposeResources12(env_1);
18364
18479
  }
18365
18480
  }
18366
18481
  _client() {
@@ -18769,7 +18884,7 @@ ${sourceUrlComment}
18769
18884
  try {
18770
18885
  const { fromSurface, omitBackground, optimizeForSpeed, quality, clip: userClip, type, captureBeyondViewport } = options;
18771
18886
  const isFirefox = this.target()._targetManager() instanceof FirefoxTargetManager;
18772
- const stack = __addDisposableResource11(env_2, new AsyncDisposableStack(), true);
18887
+ const stack = __addDisposableResource12(env_2, new AsyncDisposableStack(), true);
18773
18888
  if (!isFirefox && omitBackground && (type === "png" || type === "webp")) {
18774
18889
  await this.#emulationManager.setTransparentBackgroundColor();
18775
18890
  stack.defer(async () => {
@@ -18797,7 +18912,7 @@ ${sourceUrlComment}
18797
18912
  env_2.error = e_2;
18798
18913
  env_2.hasError = true;
18799
18914
  } finally {
18800
- const result_1 = __disposeResources11(env_2);
18915
+ const result_1 = __disposeResources12(env_2);
18801
18916
  if (result_1)
18802
18917
  await result_1;
18803
18918
  }
@@ -18849,7 +18964,7 @@ ${sourceUrlComment}
18849
18964
  async close(options = { runBeforeUnload: void 0 }) {
18850
18965
  const env_3 = { stack: [], error: void 0, hasError: false };
18851
18966
  try {
18852
- const _guard = __addDisposableResource11(env_3, await this.browserContext().waitForScreenshotOperations(), false);
18967
+ const _guard = __addDisposableResource12(env_3, await this.browserContext().waitForScreenshotOperations(), false);
18853
18968
  const connection = this.#primaryTargetClient.connection();
18854
18969
  assert(connection, "Protocol error: Connection closed. Most likely the page has been closed.");
18855
18970
  const runBeforeUnload = !!options.runBeforeUnload;
@@ -18865,7 +18980,7 @@ ${sourceUrlComment}
18865
18980
  env_3.error = e_3;
18866
18981
  env_3.hasError = true;
18867
18982
  } finally {
18868
- __disposeResources11(env_3);
18983
+ __disposeResources12(env_3);
18869
18984
  }
18870
18985
  }
18871
18986
  isClosed() {
@@ -18943,7 +19058,7 @@ ${sourceUrlComment}
18943
19058
  }
18944
19059
 
18945
19060
  // node_modules/puppeteer-core/lib/esm/puppeteer/cdp/BrowserContext.js
18946
- var __addDisposableResource12 = function(env, value, async2) {
19061
+ var __addDisposableResource13 = function(env, value, async2) {
18947
19062
  if (value !== null && value !== void 0) {
18948
19063
  if (typeof value !== "object" && typeof value !== "function") throw new TypeError("Object expected.");
18949
19064
  var dispose, inner;
@@ -18970,7 +19085,7 @@ ${sourceUrlComment}
18970
19085
  }
18971
19086
  return value;
18972
19087
  };
18973
- var __disposeResources12 = /* @__PURE__ */ function(SuppressedError2) {
19088
+ var __disposeResources13 = /* @__PURE__ */ function(SuppressedError2) {
18974
19089
  return function(env) {
18975
19090
  function fail(e) {
18976
19091
  env.error = env.hasError ? new SuppressedError2(e, env.error, "An error was suppressed during disposal.") : e;
@@ -19051,13 +19166,13 @@ ${sourceUrlComment}
19051
19166
  async newPage() {
19052
19167
  const env_1 = { stack: [], error: void 0, hasError: false };
19053
19168
  try {
19054
- const _guard = __addDisposableResource12(env_1, await this.waitForScreenshotOperations(), false);
19169
+ const _guard = __addDisposableResource13(env_1, await this.waitForScreenshotOperations(), false);
19055
19170
  return await this.#browser._createPageInContext(this.#id);
19056
19171
  } catch (e_1) {
19057
19172
  env_1.error = e_1;
19058
19173
  env_1.hasError = true;
19059
19174
  } finally {
19060
- __disposeResources12(env_1);
19175
+ __disposeResources13(env_1);
19061
19176
  }
19062
19177
  }
19063
19178
  browser() {