Skip to content

Commit 2ffdd50

Browse files
committed
sdks:js-ts:fix: bump version to 0.1.18 and add browser detection in DeepcrawlApp
1 parent 2cf8255 commit 2ffdd50

2 files changed

Lines changed: 6 additions & 4 deletions

File tree

packages/sdks/js-ts/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "deepcrawl",
3-
"version": "0.1.17",
3+
"version": "0.1.18",
44
"description": "JavaScript/TypeScript SDK for DeepCrawl API - A powerful web scraping and crawling service",
55
"main": "./dist/index.js",
66
"module": "./dist/index.mjs",

packages/sdks/js-ts/src/deepcrawl.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ export class DeepcrawlApp {
187187
>
188188
>;
189189
private config: DeepcrawlConfig;
190-
private nodeEnv: 'nodeJs' | 'cf-worker' = 'nodeJs';
190+
private nodeEnv: 'nodeJs' | 'cf-worker' | 'browser' = 'nodeJs';
191191
private httpsAgent?: Agent; // Node.js https.Agent
192192

193193
/**
@@ -223,15 +223,17 @@ export class DeepcrawlApp {
223223
...config,
224224
};
225225

226-
// Detect runtime environment in a concise, declarative way
226+
// Detect runtime environment with better browser detection
227227
this.nodeEnv =
228228
typeof process !== 'undefined' && !!process.versions?.node
229229
? 'nodeJs'
230230
: typeof globalThis.caches !== 'undefined' &&
231231
typeof (globalThis as { EdgeRuntime?: unknown }).EdgeRuntime ===
232232
'undefined'
233233
? 'cf-worker'
234-
: 'nodeJs';
234+
: typeof window !== 'undefined' || typeof navigator !== 'undefined'
235+
? 'browser'
236+
: 'nodeJs';
235237

236238
if (!this.config.apiKey) {
237239
throw new DeepcrawlAuthError('API key is required');

0 commit comments

Comments
 (0)