@browserless.io/browserless 2.7.0 → 2.8.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 (84) hide show
  1. package/CHANGELOG.md +16 -1
  2. package/bin/browserless.js +8 -4
  3. package/bin/scaffold/README.md +6 -4
  4. package/bin/scaffold/src/hello-world.http.ts +6 -1
  5. package/build/browserless.d.ts +4 -2
  6. package/build/browserless.js +9 -12
  7. package/build/exports.d.ts +1 -0
  8. package/build/exports.js +1 -0
  9. package/build/logger.d.ts +12 -0
  10. package/build/logger.js +27 -0
  11. package/build/router.d.ts +3 -2
  12. package/build/router.js +10 -6
  13. package/build/routes/chrome/http/content.post.body.json +8 -8
  14. package/build/routes/chrome/http/pdf.post.body.json +9 -9
  15. package/build/routes/chrome/http/scrape.post.body.json +8 -8
  16. package/build/routes/chrome/http/screenshot.post.body.json +8 -8
  17. package/build/routes/chromium/http/content.post.body.json +8 -8
  18. package/build/routes/chromium/http/pdf.post.body.json +9 -9
  19. package/build/routes/chromium/http/scrape.post.body.json +8 -8
  20. package/build/routes/chromium/http/screenshot.post.body.json +8 -8
  21. package/build/routes/firefox/ws/playwright.d.ts +2 -2
  22. package/build/routes/firefox/ws/playwright.js +1 -1
  23. package/build/routes/management/http/static.get.d.ts +2 -2
  24. package/build/routes/management/http/static.get.js +8 -10
  25. package/build/routes/webkit/ws/playwright.d.ts +2 -2
  26. package/build/routes/webkit/ws/playwright.js +1 -1
  27. package/build/sdk-utils.js +23 -10
  28. package/build/server.d.ts +3 -2
  29. package/build/server.js +5 -3
  30. package/build/shared/browser.ws.d.ts +2 -2
  31. package/build/shared/browser.ws.js +1 -1
  32. package/build/shared/chromium.playwright.ws.d.ts +2 -2
  33. package/build/shared/chromium.playwright.ws.js +1 -1
  34. package/build/shared/chromium.ws.d.ts +2 -2
  35. package/build/shared/chromium.ws.js +1 -1
  36. package/build/shared/content.http.d.ts +2 -2
  37. package/build/shared/content.http.js +1 -1
  38. package/build/shared/download.http.d.ts +2 -2
  39. package/build/shared/download.http.js +11 -12
  40. package/build/shared/function.http.d.ts +2 -2
  41. package/build/shared/function.http.js +4 -5
  42. package/build/shared/page.ws.d.ts +2 -2
  43. package/build/shared/page.ws.js +1 -1
  44. package/build/shared/pdf.http.d.ts +2 -2
  45. package/build/shared/pdf.http.js +1 -1
  46. package/build/shared/performance.http.d.ts +2 -2
  47. package/build/shared/performance.http.js +1 -1
  48. package/build/shared/scrape.http.d.ts +2 -2
  49. package/build/shared/scrape.http.js +1 -1
  50. package/build/shared/screenshot.http.d.ts +2 -2
  51. package/build/shared/screenshot.http.js +1 -1
  52. package/build/shared/utils/function/handler.d.ts +2 -3
  53. package/build/shared/utils/function/handler.js +7 -7
  54. package/build/types.d.ts +6 -15
  55. package/build/types.js +1 -10
  56. package/package.json +3 -3
  57. package/scripts/start.sh +2 -1
  58. package/scripts/test.sh +7 -4
  59. package/src/browserless.ts +8 -9
  60. package/src/exports.ts +1 -0
  61. package/src/logger.ts +31 -0
  62. package/src/router.ts +9 -7
  63. package/src/routes/firefox/ws/playwright.ts +2 -0
  64. package/src/routes/management/http/static.get.ts +15 -10
  65. package/src/routes/webkit/ws/playwright.ts +2 -0
  66. package/src/sdk-utils.ts +20 -2
  67. package/src/server.ts +4 -2
  68. package/src/shared/browser.ws.ts +2 -0
  69. package/src/shared/chromium.playwright.ws.ts +2 -0
  70. package/src/shared/chromium.ws.ts +2 -0
  71. package/src/shared/content.http.ts +2 -0
  72. package/src/shared/download.http.ts +14 -11
  73. package/src/shared/function.http.ts +5 -4
  74. package/src/shared/page.ws.ts +2 -0
  75. package/src/shared/pdf.http.ts +2 -0
  76. package/src/shared/performance.http.ts +2 -0
  77. package/src/shared/scrape.http.ts +2 -0
  78. package/src/shared/screenshot.http.ts +2 -0
  79. package/src/shared/utils/function/handler.ts +8 -12
  80. package/src/types.ts +5 -9
  81. package/static/docs/swagger.json +11 -11
  82. package/static/docs/swagger.min.json +10 -10
  83. package/static/function/client.js +20 -9
  84. package/static/function/index.html +20 -9
@@ -21466,7 +21466,7 @@
21466
21466
  }
21467
21467
  /**
21468
21468
  * This method fetches an element with `selector`, scrolls it into view if
21469
- * needed, and then uses {@link Page | Page.mouse} to click in the center of the
21469
+ * needed, and then uses {@link Page.mouse} to click in the center of the
21470
21470
  * element. If there's no element matching `selector`, the method throws an
21471
21471
  * error.
21472
21472
  *
@@ -21515,7 +21515,7 @@
21515
21515
  }
21516
21516
  /**
21517
21517
  * This method fetches an element with `selector`, scrolls it into view if
21518
- * needed, and then uses {@link Page | Page.mouse}
21518
+ * needed, and then uses {@link Page.mouse}
21519
21519
  * to hover over the center of the element.
21520
21520
  * If there's no element matching `selector`, the method throws an error.
21521
21521
  * @param selector - A
@@ -21562,7 +21562,7 @@
21562
21562
  }
21563
21563
  /**
21564
21564
  * This method fetches an element with `selector`, scrolls it into view if
21565
- * needed, and then uses {@link Page | Page.touchscreen}
21565
+ * needed, and then uses {@link Page.touchscreen}
21566
21566
  * to tap in the center of the element.
21567
21567
  * If there's no element matching `selector`, the method throws an error.
21568
21568
  * @param selector - A
@@ -23755,7 +23755,7 @@
23755
23755
  for (const [name2, jsValue] of Object.entries(replacements)) {
23756
23756
  value = value.replace(
23757
23757
  new RegExp(`PLACEHOLDER\\(\\s*(?:'${name2}'|"${name2}")\\s*\\)`, "g"),
23758
- // Wrapping this ensures tersers that accidently inline PLACEHOLDER calls
23758
+ // Wrapping this ensures tersers that accidentally inline PLACEHOLDER calls
23759
23759
  // are still valid. Without, we may get calls like ()=>{...}() which is
23760
23760
  // not valid.
23761
23761
  `(${jsValue})`
@@ -24108,7 +24108,16 @@
24108
24108
  role
24109
24109
  });
24110
24110
  return nodes.filter((node) => {
24111
- return !node.role || !NON_ELEMENT_NODE_ROLES.has(node.role.value);
24111
+ if (node.ignored) {
24112
+ return false;
24113
+ }
24114
+ if (!node.role) {
24115
+ return false;
24116
+ }
24117
+ if (NON_ELEMENT_NODE_ROLES.has(node.role.value)) {
24118
+ return false;
24119
+ }
24120
+ return true;
24112
24121
  });
24113
24122
  };
24114
24123
  var isKnownAttribute = (attribute) => {
@@ -24883,7 +24892,7 @@
24883
24892
  }
24884
24893
  /**
24885
24894
  * This method scrolls element into view if needed, and then
24886
- * uses {@link Page} to hover over the center of the element.
24895
+ * uses {@link Page.mouse} to hover over the center of the element.
24887
24896
  * If the element is detached from DOM, the method throws an error.
24888
24897
  */
24889
24898
  async hover() {
@@ -24893,7 +24902,7 @@
24893
24902
  }
24894
24903
  /**
24895
24904
  * This method scrolls element into view if needed, and then
24896
- * uses {@link Page | Page.mouse} to click in the center of the element.
24905
+ * uses {@link Page.mouse} to click in the center of the element.
24897
24906
  * If the element is detached from DOM, the method throws an error.
24898
24907
  */
24899
24908
  async click(options = {}) {
@@ -28092,6 +28101,7 @@ ${sourceUrlComment}
28092
28101
  // frameID -> childFrameIDs
28093
28102
  #childIds = /* @__PURE__ */ new Map();
28094
28103
  #mainFrame;
28104
+ #isMainFrameStale = false;
28095
28105
  #waitRequests = /* @__PURE__ */ new Map();
28096
28106
  getMainFrame() {
28097
28107
  return this.#mainFrame;
@@ -28124,8 +28134,9 @@ ${sourceUrlComment}
28124
28134
  this.#childIds.set(frame._parentId, /* @__PURE__ */ new Set());
28125
28135
  }
28126
28136
  this.#childIds.get(frame._parentId).add(frame._id);
28127
- } else if (!this.#mainFrame) {
28137
+ } else if (!this.#mainFrame || this.#isMainFrameStale) {
28128
28138
  this.#mainFrame = frame;
28139
+ this.#isMainFrameStale = false;
28129
28140
  }
28130
28141
  this.#waitRequests.get(frame._id)?.forEach((request) => {
28131
28142
  return request.resolve(frame);
@@ -28137,7 +28148,7 @@ ${sourceUrlComment}
28137
28148
  if (frame._parentId) {
28138
28149
  this.#childIds.get(frame._parentId)?.delete(frame._id);
28139
28150
  } else {
28140
- this.#mainFrame = void 0;
28151
+ this.#isMainFrameStale = true;
28141
28152
  }
28142
28153
  }
28143
28154
  childFrames(frameId) {
@@ -21474,7 +21474,7 @@
21474
21474
  }
21475
21475
  /**
21476
21476
  * This method fetches an element with `selector`, scrolls it into view if
21477
- * needed, and then uses {@link Page | Page.mouse} to click in the center of the
21477
+ * needed, and then uses {@link Page.mouse} to click in the center of the
21478
21478
  * element. If there's no element matching `selector`, the method throws an
21479
21479
  * error.
21480
21480
  *
@@ -21523,7 +21523,7 @@
21523
21523
  }
21524
21524
  /**
21525
21525
  * This method fetches an element with `selector`, scrolls it into view if
21526
- * needed, and then uses {@link Page | Page.mouse}
21526
+ * needed, and then uses {@link Page.mouse}
21527
21527
  * to hover over the center of the element.
21528
21528
  * If there's no element matching `selector`, the method throws an error.
21529
21529
  * @param selector - A
@@ -21570,7 +21570,7 @@
21570
21570
  }
21571
21571
  /**
21572
21572
  * This method fetches an element with `selector`, scrolls it into view if
21573
- * needed, and then uses {@link Page | Page.touchscreen}
21573
+ * needed, and then uses {@link Page.touchscreen}
21574
21574
  * to tap in the center of the element.
21575
21575
  * If there's no element matching `selector`, the method throws an error.
21576
21576
  * @param selector - A
@@ -23763,7 +23763,7 @@
23763
23763
  for (const [name2, jsValue] of Object.entries(replacements)) {
23764
23764
  value = value.replace(
23765
23765
  new RegExp(`PLACEHOLDER\\(\\s*(?:'${name2}'|"${name2}")\\s*\\)`, "g"),
23766
- // Wrapping this ensures tersers that accidently inline PLACEHOLDER calls
23766
+ // Wrapping this ensures tersers that accidentally inline PLACEHOLDER calls
23767
23767
  // are still valid. Without, we may get calls like ()=>{...}() which is
23768
23768
  // not valid.
23769
23769
  `(${jsValue})`
@@ -24116,7 +24116,16 @@
24116
24116
  role
24117
24117
  });
24118
24118
  return nodes.filter((node) => {
24119
- return !node.role || !NON_ELEMENT_NODE_ROLES.has(node.role.value);
24119
+ if (node.ignored) {
24120
+ return false;
24121
+ }
24122
+ if (!node.role) {
24123
+ return false;
24124
+ }
24125
+ if (NON_ELEMENT_NODE_ROLES.has(node.role.value)) {
24126
+ return false;
24127
+ }
24128
+ return true;
24120
24129
  });
24121
24130
  };
24122
24131
  var isKnownAttribute = (attribute) => {
@@ -24891,7 +24900,7 @@
24891
24900
  }
24892
24901
  /**
24893
24902
  * This method scrolls element into view if needed, and then
24894
- * uses {@link Page} to hover over the center of the element.
24903
+ * uses {@link Page.mouse} to hover over the center of the element.
24895
24904
  * If the element is detached from DOM, the method throws an error.
24896
24905
  */
24897
24906
  async hover() {
@@ -24901,7 +24910,7 @@
24901
24910
  }
24902
24911
  /**
24903
24912
  * This method scrolls element into view if needed, and then
24904
- * uses {@link Page | Page.mouse} to click in the center of the element.
24913
+ * uses {@link Page.mouse} to click in the center of the element.
24905
24914
  * If the element is detached from DOM, the method throws an error.
24906
24915
  */
24907
24916
  async click(options = {}) {
@@ -28100,6 +28109,7 @@ ${sourceUrlComment}
28100
28109
  // frameID -> childFrameIDs
28101
28110
  #childIds = /* @__PURE__ */ new Map();
28102
28111
  #mainFrame;
28112
+ #isMainFrameStale = false;
28103
28113
  #waitRequests = /* @__PURE__ */ new Map();
28104
28114
  getMainFrame() {
28105
28115
  return this.#mainFrame;
@@ -28132,8 +28142,9 @@ ${sourceUrlComment}
28132
28142
  this.#childIds.set(frame._parentId, /* @__PURE__ */ new Set());
28133
28143
  }
28134
28144
  this.#childIds.get(frame._parentId).add(frame._id);
28135
- } else if (!this.#mainFrame) {
28145
+ } else if (!this.#mainFrame || this.#isMainFrameStale) {
28136
28146
  this.#mainFrame = frame;
28147
+ this.#isMainFrameStale = false;
28137
28148
  }
28138
28149
  this.#waitRequests.get(frame._id)?.forEach((request) => {
28139
28150
  return request.resolve(frame);
@@ -28145,7 +28156,7 @@ ${sourceUrlComment}
28145
28156
  if (frame._parentId) {
28146
28157
  this.#childIds.get(frame._parentId)?.delete(frame._id);
28147
28158
  } else {
28148
- this.#mainFrame = void 0;
28159
+ this.#isMainFrameStale = true;
28149
28160
  }
28150
28161
  }
28151
28162
  childFrames(frameId) {