@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
@@ -2006,50 +2006,64 @@
2006
2006
  createDebug.namespaces = namespaces;
2007
2007
  createDebug.names = [];
2008
2008
  createDebug.skips = [];
2009
- let i;
2010
- const split = (typeof namespaces === "string" ? namespaces : "").split(/[\s,]+/);
2011
- const len = split.length;
2012
- for (i = 0; i < len; i++) {
2013
- if (!split[i]) {
2014
- continue;
2009
+ const split = (typeof namespaces === "string" ? namespaces : "").trim().replace(" ", ",").split(",").filter(Boolean);
2010
+ for (const ns of split) {
2011
+ if (ns[0] === "-") {
2012
+ createDebug.skips.push(ns.slice(1));
2013
+ } else {
2014
+ createDebug.names.push(ns);
2015
2015
  }
2016
- namespaces = split[i].replace(/\*/g, ".*?");
2017
- if (namespaces[0] === "-") {
2018
- createDebug.skips.push(new RegExp("^" + namespaces.slice(1) + "$"));
2016
+ }
2017
+ }
2018
+ function matchesTemplate(search, template) {
2019
+ let searchIndex = 0;
2020
+ let templateIndex = 0;
2021
+ let starIndex = -1;
2022
+ let matchIndex = 0;
2023
+ while (searchIndex < search.length) {
2024
+ if (templateIndex < template.length && (template[templateIndex] === search[searchIndex] || template[templateIndex] === "*")) {
2025
+ if (template[templateIndex] === "*") {
2026
+ starIndex = templateIndex;
2027
+ matchIndex = searchIndex;
2028
+ templateIndex++;
2029
+ } else {
2030
+ searchIndex++;
2031
+ templateIndex++;
2032
+ }
2033
+ } else if (starIndex !== -1) {
2034
+ templateIndex = starIndex + 1;
2035
+ matchIndex++;
2036
+ searchIndex = matchIndex;
2019
2037
  } else {
2020
- createDebug.names.push(new RegExp("^" + namespaces + "$"));
2038
+ return false;
2021
2039
  }
2022
2040
  }
2041
+ while (templateIndex < template.length && template[templateIndex] === "*") {
2042
+ templateIndex++;
2043
+ }
2044
+ return templateIndex === template.length;
2023
2045
  }
2024
2046
  function disable() {
2025
2047
  const namespaces = [
2026
- ...createDebug.names.map(toNamespace),
2027
- ...createDebug.skips.map(toNamespace).map((namespace) => "-" + namespace)
2048
+ ...createDebug.names,
2049
+ ...createDebug.skips.map((namespace) => "-" + namespace)
2028
2050
  ].join(",");
2029
2051
  createDebug.enable("");
2030
2052
  return namespaces;
2031
2053
  }
2032
2054
  function enabled(name) {
2033
- if (name[name.length - 1] === "*") {
2034
- return true;
2035
- }
2036
- let i;
2037
- let len;
2038
- for (i = 0, len = createDebug.skips.length; i < len; i++) {
2039
- if (createDebug.skips[i].test(name)) {
2055
+ for (const skip of createDebug.skips) {
2056
+ if (matchesTemplate(name, skip)) {
2040
2057
  return false;
2041
2058
  }
2042
2059
  }
2043
- for (i = 0, len = createDebug.names.length; i < len; i++) {
2044
- if (createDebug.names[i].test(name)) {
2060
+ for (const ns of createDebug.names) {
2061
+ if (matchesTemplate(name, ns)) {
2045
2062
  return true;
2046
2063
  }
2047
2064
  }
2048
2065
  return false;
2049
2066
  }
2050
- function toNamespace(regexp) {
2051
- return regexp.toString().substring(2, regexp.toString().length - 2).replace(/\.\*\?$/, "*");
2052
- }
2053
2067
  function coerce(val) {
2054
2068
  if (val instanceof Error) {
2055
2069
  return val.stack || val.message;
@@ -4387,7 +4401,7 @@
4387
4401
  // node_modules/puppeteer-core/lib/esm/puppeteer/generated/version.js
4388
4402
  init_dirname();
4389
4403
  init_buffer2();
4390
- var packageVersion = "23.10.0";
4404
+ var packageVersion = "23.11.1";
4391
4405
 
4392
4406
  // node_modules/puppeteer-core/lib/esm/puppeteer/util/assert.js
4393
4407
  init_dirname();
@@ -9520,6 +9534,7 @@
9520
9534
  "blurredVision",
9521
9535
  "deuteranopia",
9522
9536
  "protanopia",
9537
+ "reducedContrast",
9523
9538
  "tritanopia"
9524
9539
  ]);
9525
9540
  assert(!type || visionDeficiencies.has(type), `Unsupported vision deficiency: ${type}`);
@@ -13869,13 +13884,73 @@ ${sourceUrlComment}
13869
13884
  // node_modules/puppeteer-core/lib/esm/puppeteer/cdp/Accessibility.js
13870
13885
  init_dirname();
13871
13886
  init_buffer2();
13887
+ var __addDisposableResource11 = function(env, value, async2) {
13888
+ if (value !== null && value !== void 0) {
13889
+ if (typeof value !== "object" && typeof value !== "function") throw new TypeError("Object expected.");
13890
+ var dispose, inner;
13891
+ if (async2) {
13892
+ if (!Symbol.asyncDispose) throw new TypeError("Symbol.asyncDispose is not defined.");
13893
+ dispose = value[Symbol.asyncDispose];
13894
+ }
13895
+ if (dispose === void 0) {
13896
+ if (!Symbol.dispose) throw new TypeError("Symbol.dispose is not defined.");
13897
+ dispose = value[Symbol.dispose];
13898
+ if (async2) inner = dispose;
13899
+ }
13900
+ if (typeof dispose !== "function") throw new TypeError("Object not disposable.");
13901
+ if (inner) dispose = function() {
13902
+ try {
13903
+ inner.call(this);
13904
+ } catch (e) {
13905
+ return Promise.reject(e);
13906
+ }
13907
+ };
13908
+ env.stack.push({ value, dispose, async: async2 });
13909
+ } else if (async2) {
13910
+ env.stack.push({ async: true });
13911
+ }
13912
+ return value;
13913
+ };
13914
+ var __disposeResources11 = /* @__PURE__ */ function(SuppressedError2) {
13915
+ return function(env) {
13916
+ function fail(e) {
13917
+ env.error = env.hasError ? new SuppressedError2(e, env.error, "An error was suppressed during disposal.") : e;
13918
+ env.hasError = true;
13919
+ }
13920
+ var r, s = 0;
13921
+ function next() {
13922
+ while (r = env.stack.pop()) {
13923
+ try {
13924
+ if (!r.async && s === 1) return s = 0, env.stack.push(r), Promise.resolve().then(next);
13925
+ if (r.dispose) {
13926
+ var result = r.dispose.call(r.value);
13927
+ if (r.async) return s |= 2, Promise.resolve(result).then(next, function(e) {
13928
+ fail(e);
13929
+ return next();
13930
+ });
13931
+ } else s |= 1;
13932
+ } catch (e) {
13933
+ fail(e);
13934
+ }
13935
+ }
13936
+ if (s === 1) return env.hasError ? Promise.reject(env.error) : Promise.resolve();
13937
+ if (env.hasError) throw env.error;
13938
+ }
13939
+ return next();
13940
+ };
13941
+ }(typeof SuppressedError === "function" ? SuppressedError : function(error, suppressed, message) {
13942
+ var e = new Error(message);
13943
+ return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
13944
+ });
13872
13945
  var Accessibility = class {
13873
13946
  #realm;
13947
+ #frameId;
13874
13948
  /**
13875
13949
  * @internal
13876
13950
  */
13877
- constructor(realm) {
13951
+ constructor(realm, frameId = "") {
13878
13952
  this.#realm = realm;
13953
+ this.#frameId = frameId;
13879
13954
  }
13880
13955
  /**
13881
13956
  * Captures the current state of the accessibility tree.
@@ -13917,8 +13992,10 @@ ${sourceUrlComment}
13917
13992
  * @returns An AXNode object representing the snapshot.
13918
13993
  */
13919
13994
  async snapshot(options = {}) {
13920
- const { interestingOnly = true, root = null } = options;
13921
- const { nodes } = await this.#realm.environment.client.send("Accessibility.getFullAXTree");
13995
+ const { interestingOnly = true, root = null, includeIframes = false } = options;
13996
+ const { nodes } = await this.#realm.environment.client.send("Accessibility.getFullAXTree", {
13997
+ frameId: this.#frameId
13998
+ });
13922
13999
  let backendNodeId;
13923
14000
  if (root) {
13924
14001
  const { node } = await this.#realm.environment.client.send("DOM.describeNode", {
@@ -13927,10 +14004,41 @@ ${sourceUrlComment}
13927
14004
  backendNodeId = node.backendNodeId;
13928
14005
  }
13929
14006
  const defaultRoot = AXNode.createTree(this.#realm, nodes);
14007
+ const populateIframes = async (root2) => {
14008
+ if (root2.payload.role?.value === "Iframe") {
14009
+ const env_1 = { stack: [], error: void 0, hasError: false };
14010
+ try {
14011
+ if (!root2.payload.backendDOMNodeId) {
14012
+ return;
14013
+ }
14014
+ const handle = __addDisposableResource11(env_1, await this.#realm.adoptBackendNode(root2.payload.backendDOMNodeId), false);
14015
+ if (!handle || !("contentFrame" in handle)) {
14016
+ return;
14017
+ }
14018
+ const frame = await handle.contentFrame();
14019
+ if (!frame) {
14020
+ return;
14021
+ }
14022
+ const iframeSnapshot = await frame.accessibility.snapshot(options);
14023
+ root2.iframeSnapshot = iframeSnapshot ?? void 0;
14024
+ } catch (e_1) {
14025
+ env_1.error = e_1;
14026
+ env_1.hasError = true;
14027
+ } finally {
14028
+ __disposeResources11(env_1);
14029
+ }
14030
+ }
14031
+ for (const child of root2.children) {
14032
+ await populateIframes(child);
14033
+ }
14034
+ };
13930
14035
  let needle = defaultRoot;
13931
14036
  if (!defaultRoot) {
13932
14037
  return null;
13933
14038
  }
14039
+ if (includeIframes) {
14040
+ await populateIframes(defaultRoot);
14041
+ }
13934
14042
  if (backendNodeId) {
13935
14043
  needle = defaultRoot.find((node) => {
13936
14044
  return node.payload.backendDOMNodeId === backendNodeId;
@@ -13961,10 +14069,16 @@ ${sourceUrlComment}
13961
14069
  if (children.length) {
13962
14070
  serializedNode.children = children;
13963
14071
  }
14072
+ if (node.iframeSnapshot) {
14073
+ if (!serializedNode.children) {
14074
+ serializedNode.children = [];
14075
+ }
14076
+ serializedNode.children.push(node.iframeSnapshot);
14077
+ }
13964
14078
  return [serializedNode];
13965
14079
  }
13966
14080
  collectInterestingNodes(collection, node, insideControl) {
13967
- if (node.isInteresting(insideControl)) {
14081
+ if (node.isInteresting(insideControl) || node.iframeSnapshot) {
13968
14082
  collection.add(node);
13969
14083
  }
13970
14084
  if (node.isLeafNode()) {
@@ -13979,6 +14093,7 @@ ${sourceUrlComment}
13979
14093
  var AXNode = class _AXNode {
13980
14094
  payload;
13981
14095
  children = [];
14096
+ iframeSnapshot;
13982
14097
  #richlyEditable = false;
13983
14098
  #editable = false;
13984
14099
  #focusable = false;
@@ -14839,7 +14954,7 @@ ${sourceUrlComment}
14839
14954
  [MAIN_WORLD]: new IsolatedWorld(this, this._frameManager.timeoutSettings),
14840
14955
  [PUPPETEER_WORLD]: new IsolatedWorld(this, this._frameManager.timeoutSettings)
14841
14956
  };
14842
- this.accessibility = new Accessibility(this.worlds[MAIN_WORLD]);
14957
+ this.accessibility = new Accessibility(this.worlds[MAIN_WORLD], frameId);
14843
14958
  this.on(FrameEvent.FrameSwappedByActivation, () => {
14844
14959
  this._onLoadingStarted();
14845
14960
  this._onLoadingStopped();
@@ -18089,7 +18204,7 @@ ${sourceUrlComment}
18089
18204
  };
18090
18205
 
18091
18206
  // node_modules/puppeteer-core/lib/esm/puppeteer/cdp/Page.js
18092
- var __addDisposableResource11 = function(env, value, async2) {
18207
+ var __addDisposableResource12 = function(env, value, async2) {
18093
18208
  if (value !== null && value !== void 0) {
18094
18209
  if (typeof value !== "object" && typeof value !== "function") throw new TypeError("Object expected.");
18095
18210
  var dispose, inner;
@@ -18116,7 +18231,7 @@ ${sourceUrlComment}
18116
18231
  }
18117
18232
  return value;
18118
18233
  };
18119
- var __disposeResources11 = /* @__PURE__ */ function(SuppressedError2) {
18234
+ var __disposeResources12 = /* @__PURE__ */ function(SuppressedError2) {
18120
18235
  return function(env) {
18121
18236
  function fail(e) {
18122
18237
  env.error = env.hasError ? new SuppressedError2(e, env.error, "An error was suppressed during disposal.") : e;
@@ -18358,7 +18473,7 @@ ${sourceUrlComment}
18358
18473
  }
18359
18474
  const frame = this.#frameManager.frame(event.frameId);
18360
18475
  assert(frame, "This should never happen.");
18361
- const handle = __addDisposableResource11(env_1, await frame.worlds[MAIN_WORLD].adoptBackendNode(event.backendNodeId), false);
18476
+ const handle = __addDisposableResource12(env_1, await frame.worlds[MAIN_WORLD].adoptBackendNode(event.backendNodeId), false);
18362
18477
  const fileChooser = new FileChooser(handle.move(), event);
18363
18478
  for (const promise of this.#fileChooserDeferreds) {
18364
18479
  promise.resolve(fileChooser);
@@ -18368,7 +18483,7 @@ ${sourceUrlComment}
18368
18483
  env_1.error = e_1;
18369
18484
  env_1.hasError = true;
18370
18485
  } finally {
18371
- __disposeResources11(env_1);
18486
+ __disposeResources12(env_1);
18372
18487
  }
18373
18488
  }
18374
18489
  _client() {
@@ -18777,7 +18892,7 @@ ${sourceUrlComment}
18777
18892
  try {
18778
18893
  const { fromSurface, omitBackground, optimizeForSpeed, quality, clip: userClip, type, captureBeyondViewport } = options;
18779
18894
  const isFirefox = this.target()._targetManager() instanceof FirefoxTargetManager;
18780
- const stack = __addDisposableResource11(env_2, new AsyncDisposableStack(), true);
18895
+ const stack = __addDisposableResource12(env_2, new AsyncDisposableStack(), true);
18781
18896
  if (!isFirefox && omitBackground && (type === "png" || type === "webp")) {
18782
18897
  await this.#emulationManager.setTransparentBackgroundColor();
18783
18898
  stack.defer(async () => {
@@ -18805,7 +18920,7 @@ ${sourceUrlComment}
18805
18920
  env_2.error = e_2;
18806
18921
  env_2.hasError = true;
18807
18922
  } finally {
18808
- const result_1 = __disposeResources11(env_2);
18923
+ const result_1 = __disposeResources12(env_2);
18809
18924
  if (result_1)
18810
18925
  await result_1;
18811
18926
  }
@@ -18857,7 +18972,7 @@ ${sourceUrlComment}
18857
18972
  async close(options = { runBeforeUnload: void 0 }) {
18858
18973
  const env_3 = { stack: [], error: void 0, hasError: false };
18859
18974
  try {
18860
- const _guard = __addDisposableResource11(env_3, await this.browserContext().waitForScreenshotOperations(), false);
18975
+ const _guard = __addDisposableResource12(env_3, await this.browserContext().waitForScreenshotOperations(), false);
18861
18976
  const connection = this.#primaryTargetClient.connection();
18862
18977
  assert(connection, "Protocol error: Connection closed. Most likely the page has been closed.");
18863
18978
  const runBeforeUnload = !!options.runBeforeUnload;
@@ -18873,7 +18988,7 @@ ${sourceUrlComment}
18873
18988
  env_3.error = e_3;
18874
18989
  env_3.hasError = true;
18875
18990
  } finally {
18876
- __disposeResources11(env_3);
18991
+ __disposeResources12(env_3);
18877
18992
  }
18878
18993
  }
18879
18994
  isClosed() {
@@ -18951,7 +19066,7 @@ ${sourceUrlComment}
18951
19066
  }
18952
19067
 
18953
19068
  // node_modules/puppeteer-core/lib/esm/puppeteer/cdp/BrowserContext.js
18954
- var __addDisposableResource12 = function(env, value, async2) {
19069
+ var __addDisposableResource13 = function(env, value, async2) {
18955
19070
  if (value !== null && value !== void 0) {
18956
19071
  if (typeof value !== "object" && typeof value !== "function") throw new TypeError("Object expected.");
18957
19072
  var dispose, inner;
@@ -18978,7 +19093,7 @@ ${sourceUrlComment}
18978
19093
  }
18979
19094
  return value;
18980
19095
  };
18981
- var __disposeResources12 = /* @__PURE__ */ function(SuppressedError2) {
19096
+ var __disposeResources13 = /* @__PURE__ */ function(SuppressedError2) {
18982
19097
  return function(env) {
18983
19098
  function fail(e) {
18984
19099
  env.error = env.hasError ? new SuppressedError2(e, env.error, "An error was suppressed during disposal.") : e;
@@ -19059,13 +19174,13 @@ ${sourceUrlComment}
19059
19174
  async newPage() {
19060
19175
  const env_1 = { stack: [], error: void 0, hasError: false };
19061
19176
  try {
19062
- const _guard = __addDisposableResource12(env_1, await this.waitForScreenshotOperations(), false);
19177
+ const _guard = __addDisposableResource13(env_1, await this.waitForScreenshotOperations(), false);
19063
19178
  return await this.#browser._createPageInContext(this.#id);
19064
19179
  } catch (e_1) {
19065
19180
  env_1.error = e_1;
19066
19181
  env_1.hasError = true;
19067
19182
  } finally {
19068
- __disposeResources12(env_1);
19183
+ __disposeResources13(env_1);
19069
19184
  }
19070
19185
  }
19071
19186
  browser() {