@spider-cloud/spider-client 0.1.24 → 0.1.26
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.
package/dist/config.d.ts
CHANGED
|
@@ -297,9 +297,9 @@ export interface SpiderParams {
|
|
|
297
297
|
*/
|
|
298
298
|
sitemap?: boolean;
|
|
299
299
|
/**
|
|
300
|
-
*
|
|
300
|
+
* Specifies whether to only use the sitemap links.
|
|
301
301
|
*/
|
|
302
|
-
|
|
302
|
+
sitemap_only?: boolean;
|
|
303
303
|
/**
|
|
304
304
|
* External domains to include the crawl.
|
|
305
305
|
*/
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import type { SpiderCoreResponse } from "../config";
|
|
2
|
-
export declare const
|
|
2
|
+
export declare const createJsonLineProcessor: (cb: (r: SpiderCoreResponse) => void) => (chunk: Buffer | string) => void;
|
|
@@ -1,13 +1,21 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
4
|
-
const
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
3
|
+
exports.createJsonLineProcessor = void 0;
|
|
4
|
+
const createJsonLineProcessor = (cb) => {
|
|
5
|
+
let buffer = "";
|
|
6
|
+
return (chunk) => {
|
|
7
|
+
buffer += chunk.toString();
|
|
8
|
+
let boundary;
|
|
9
|
+
while ((boundary = buffer.indexOf("\n")) !== -1) {
|
|
10
|
+
const line = buffer.slice(0, boundary);
|
|
11
|
+
buffer = buffer.slice(boundary + 1);
|
|
12
|
+
if (line.trim()) {
|
|
13
|
+
try {
|
|
14
|
+
cb(JSON.parse(line));
|
|
15
|
+
}
|
|
16
|
+
catch (_error) { }
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
};
|
|
12
20
|
};
|
|
13
|
-
exports.
|
|
21
|
+
exports.createJsonLineProcessor = createJsonLineProcessor;
|
|
@@ -2,12 +2,13 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.streamReader = void 0;
|
|
4
4
|
const process_chunk_1 = require("./process-chunk");
|
|
5
|
-
//
|
|
5
|
+
// Stream the response via callbacks.
|
|
6
6
|
const streamReader = async (res, cb) => {
|
|
7
7
|
var _a;
|
|
8
8
|
if (res.ok) {
|
|
9
9
|
const reader = (_a = res.body) === null || _a === void 0 ? void 0 : _a.getReader();
|
|
10
10
|
const decoder = new TextDecoder();
|
|
11
|
+
const processChunk = (0, process_chunk_1.createJsonLineProcessor)(cb);
|
|
11
12
|
if (reader) {
|
|
12
13
|
while (true) {
|
|
13
14
|
const { done, value } = await reader.read();
|
|
@@ -15,8 +16,9 @@ const streamReader = async (res, cb) => {
|
|
|
15
16
|
break;
|
|
16
17
|
}
|
|
17
18
|
const chunk = decoder.decode(value, { stream: true });
|
|
18
|
-
|
|
19
|
+
processChunk(chunk);
|
|
19
20
|
}
|
|
21
|
+
processChunk(decoder.decode(new Uint8Array(), { stream: false }));
|
|
20
22
|
}
|
|
21
23
|
}
|
|
22
24
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@spider-cloud/spider-client",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.26",
|
|
4
4
|
"description": "Isomorphic Javascript SDK for Spider Cloud services",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"test": "node --import tsx --test __tests__/*test.ts",
|
|
@@ -20,13 +20,13 @@
|
|
|
20
20
|
"api",
|
|
21
21
|
"llm scraping"
|
|
22
22
|
],
|
|
23
|
-
"author": "Jeff Mendez<jeff@
|
|
23
|
+
"author": "Jeff Mendez<jeff@spider.cloud>",
|
|
24
24
|
"license": "MIT",
|
|
25
25
|
"devDependencies": {
|
|
26
|
-
"@types/node": "22.10.
|
|
26
|
+
"@types/node": "22.10.7",
|
|
27
27
|
"dotenv": "^16.4.7",
|
|
28
28
|
"tsx": "^4.19.2",
|
|
29
|
-
"typescript": "5.7.
|
|
29
|
+
"typescript": "5.7.3"
|
|
30
30
|
},
|
|
31
31
|
"dependencies": {
|
|
32
32
|
"exponential-backoff": "^3.1.1"
|