firecrawl 4.5.0 → 4.5.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.
@@ -8,7 +8,7 @@ var require_package = __commonJS({
8
8
  "package.json"(exports, module) {
9
9
  module.exports = {
10
10
  name: "@mendable/firecrawl-js",
11
- version: "4.5.0",
11
+ version: "4.5.1",
12
12
  description: "JavaScript SDK for Firecrawl API",
13
13
  main: "dist/index.js",
14
14
  types: "dist/index.d.ts",
@@ -36,6 +36,7 @@ var require_package = __commonJS({
36
36
  dependencies: {
37
37
  axios: "^1.12.2",
38
38
  "typescript-event-target": "^1.1.1",
39
+ ws: "^8.18.3",
39
40
  zod: "^3.23.8",
40
41
  "zod-to-json-schema": "^3.23.0"
41
42
  },
@@ -50,6 +51,7 @@ var require_package = __commonJS({
50
51
  "@types/mocha": "^10.0.6",
51
52
  "@types/node": "^20.12.12",
52
53
  "@types/uuid": "^9.0.8",
54
+ "@types/ws": "^8.18.1",
53
55
  dotenv: "^16.4.5",
54
56
  jest: "^30.0.5",
55
57
  "ts-jest": "^29.4.0",
package/dist/index.cjs CHANGED
@@ -35,7 +35,7 @@ var require_package = __commonJS({
35
35
  "package.json"(exports2, module2) {
36
36
  module2.exports = {
37
37
  name: "@mendable/firecrawl-js",
38
- version: "4.5.0",
38
+ version: "4.5.1",
39
39
  description: "JavaScript SDK for Firecrawl API",
40
40
  main: "dist/index.js",
41
41
  types: "dist/index.d.ts",
@@ -63,6 +63,7 @@ var require_package = __commonJS({
63
63
  dependencies: {
64
64
  axios: "^1.12.2",
65
65
  "typescript-event-target": "^1.1.1",
66
+ ws: "^8.18.3",
66
67
  zod: "^3.23.8",
67
68
  "zod-to-json-schema": "^3.23.0"
68
69
  },
@@ -77,6 +78,7 @@ var require_package = __commonJS({
77
78
  "@types/mocha": "^10.0.6",
78
79
  "@types/node": "^20.12.12",
79
80
  "@types/uuid": "^9.0.8",
81
+ "@types/ws": "^8.18.1",
80
82
  dotenv: "^16.4.5",
81
83
  jest: "^30.0.5",
82
84
  "ts-jest": "^29.4.0",
@@ -823,6 +825,7 @@ async function getTokenUsageHistorical(http, byApiKey) {
823
825
 
824
826
  // src/v2/watcher.ts
825
827
  var import_events = require("events");
828
+ var import_ws = require("ws");
826
829
  var Watcher = class extends import_events.EventEmitter {
827
830
  http;
828
831
  jobId;
@@ -848,9 +851,15 @@ var Watcher = class extends import_events.EventEmitter {
848
851
  async start() {
849
852
  try {
850
853
  const url = this.buildWsUrl();
851
- this.ws = new WebSocket(url, this.http.getApiKey());
852
- this.attachWsHandlers(this.ws);
853
- } catch {
854
+ if (typeof WebSocket !== "undefined") {
855
+ this.ws = new WebSocket(url, this.http.getApiKey());
856
+ } else {
857
+ this.ws = new import_ws.WebSocket(url, this.http.getApiKey());
858
+ }
859
+ if (this.ws) {
860
+ this.attachWsHandlers(this.ws);
861
+ }
862
+ } catch (err) {
854
863
  this.pollLoop();
855
864
  }
856
865
  }
@@ -878,7 +887,9 @@ var Watcher = class extends import_events.EventEmitter {
878
887
  return;
879
888
  }
880
889
  if (type === "done") {
881
- this.emit("done", { status: "completed", data: [], id: this.jobId });
890
+ const payload2 = body.data || body;
891
+ const data = payload2.data || [];
892
+ this.emit("done", { status: "completed", data, id: this.jobId });
882
893
  this.close();
883
894
  return;
884
895
  }
package/dist/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  require_package
3
- } from "./chunk-MVAMVUST.js";
3
+ } from "./chunk-TNGVHCPH.js";
4
4
 
5
5
  // src/v2/utils/httpClient.ts
6
6
  import axios from "axios";
@@ -707,6 +707,7 @@ async function getTokenUsageHistorical(http, byApiKey) {
707
707
 
708
708
  // src/v2/watcher.ts
709
709
  import { EventEmitter } from "events";
710
+ import { WebSocket as WS } from "ws";
710
711
  var Watcher = class extends EventEmitter {
711
712
  http;
712
713
  jobId;
@@ -732,9 +733,15 @@ var Watcher = class extends EventEmitter {
732
733
  async start() {
733
734
  try {
734
735
  const url = this.buildWsUrl();
735
- this.ws = new WebSocket(url, this.http.getApiKey());
736
- this.attachWsHandlers(this.ws);
737
- } catch {
736
+ if (typeof WebSocket !== "undefined") {
737
+ this.ws = new WebSocket(url, this.http.getApiKey());
738
+ } else {
739
+ this.ws = new WS(url, this.http.getApiKey());
740
+ }
741
+ if (this.ws) {
742
+ this.attachWsHandlers(this.ws);
743
+ }
744
+ } catch (err) {
738
745
  this.pollLoop();
739
746
  }
740
747
  }
@@ -762,7 +769,9 @@ var Watcher = class extends EventEmitter {
762
769
  return;
763
770
  }
764
771
  if (type === "done") {
765
- this.emit("done", { status: "completed", data: [], id: this.jobId });
772
+ const payload2 = body.data || body;
773
+ const data = payload2.data || [];
774
+ this.emit("done", { status: "completed", data, id: this.jobId });
766
775
  this.close();
767
776
  return;
768
777
  }
@@ -1071,7 +1080,7 @@ var FirecrawlApp = class {
1071
1080
  if (typeof process !== "undefined" && process.env && process.env.npm_package_version) {
1072
1081
  return process.env.npm_package_version;
1073
1082
  }
1074
- const packageJson = await import("./package-O4UQBIGU.js");
1083
+ const packageJson = await import("./package-SV2UYR6U.js");
1075
1084
  return packageJson.default.version;
1076
1085
  } catch (error) {
1077
1086
  const isTest = typeof process !== "undefined" && (process.env.JEST_WORKER_ID != null || false);
@@ -1,4 +1,4 @@
1
1
  import {
2
2
  require_package
3
- } from "./chunk-MVAMVUST.js";
3
+ } from "./chunk-TNGVHCPH.js";
4
4
  export default require_package();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "firecrawl",
3
- "version": "4.5.0",
3
+ "version": "4.5.1",
4
4
  "description": "JavaScript SDK for Firecrawl API",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -28,6 +28,7 @@
28
28
  "dependencies": {
29
29
  "axios": "^1.12.2",
30
30
  "typescript-event-target": "^1.1.1",
31
+ "ws": "^8.18.3",
31
32
  "zod": "^3.23.8",
32
33
  "zod-to-json-schema": "^3.23.0"
33
34
  },
@@ -42,6 +43,7 @@
42
43
  "@types/mocha": "^10.0.6",
43
44
  "@types/node": "^20.12.12",
44
45
  "@types/uuid": "^9.0.8",
46
+ "@types/ws": "^8.18.1",
45
47
  "dotenv": "^16.4.5",
46
48
  "jest": "^30.0.5",
47
49
  "ts-jest": "^29.4.0",
package/src/v2/watcher.ts CHANGED
@@ -3,6 +3,7 @@ import type { BatchScrapeJob, CrawlJob, Document } from "./types";
3
3
  import type { HttpClient } from "./utils/httpClient";
4
4
  import { getBatchScrapeStatus } from "./methods/batch";
5
5
  import { getCrawlStatus } from "./methods/crawl";
6
+ import { WebSocket as WS } from "ws";
6
7
 
7
8
  type JobKind = "crawl" | "batch";
8
9
 
@@ -43,11 +44,17 @@ export class Watcher extends EventEmitter {
43
44
  async start(): Promise<void> {
44
45
  try {
45
46
  const url = this.buildWsUrl();
46
- // Pass API key as subprotocol for browser compatibility
47
- this.ws = new WebSocket(url, this.http.getApiKey());
48
- this.attachWsHandlers(this.ws);
49
- } catch {
50
- // Fallback to polling immediately
47
+
48
+ if (typeof WebSocket !== 'undefined') {
49
+ this.ws = new WebSocket(url, this.http.getApiKey()) as any;
50
+ } else {
51
+ this.ws = new WS(url, this.http.getApiKey()) as any;
52
+ }
53
+
54
+ if (this.ws) {
55
+ this.attachWsHandlers(this.ws);
56
+ }
57
+ } catch (err) {
51
58
  this.pollLoop();
52
59
  }
53
60
  }
@@ -76,7 +83,9 @@ export class Watcher extends EventEmitter {
76
83
  return;
77
84
  }
78
85
  if (type === "done") {
79
- this.emit("done", { status: "completed", data: [], id: this.jobId });
86
+ const payload = body.data || body;
87
+ const data = (payload.data || []) as Document[];
88
+ this.emit("done", { status: "completed", data, id: this.jobId });
80
89
  this.close();
81
90
  return;
82
91
  }
package/tsup.config.ts CHANGED
@@ -8,6 +8,7 @@ export default defineConfig({
8
8
  clean: true,
9
9
  platform: "node",
10
10
  target: "node22",
11
+ external: ["ws"],
11
12
  noExternal: ["typescript-event-target"],
12
13
  esbuildOptions(options) {
13
14
  options.define = {