@browserbasehq/sdk 2.14.0 → 2.14.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.
- package/CHANGELOG.md +6 -0
- package/README.md +11 -7
- package/_shims/README.md +5 -2
- package/_shims/auto/runtime-node.d.ts +2 -4
- package/_shims/auto/runtime-node.d.ts.map +1 -1
- package/_shims/auto/runtime-node.js +43 -15
- package/_shims/auto/runtime-node.js.map +1 -1
- package/_shims/auto/runtime-node.mjs +42 -1
- package/_shims/auto/runtime-node.mjs.map +1 -1
- package/_shims/index.d.ts +4 -0
- package/_shims/node-types.d.ts +3 -0
- package/index.d.mts +6 -4
- package/index.d.ts +6 -4
- package/index.d.ts.map +1 -1
- package/index.js.map +1 -1
- package/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/_shims/README.md +5 -2
- package/src/_shims/auto/runtime-node.ts +60 -1
- package/src/_shims/index.d.ts +4 -0
- package/src/_shims/node-types.d.ts +3 -0
- package/src/index.ts +6 -4
- package/src/version.ts +1 -1
- package/version.d.ts +1 -1
- package/version.js +1 -1
- package/version.mjs +1 -1
package/CHANGELOG.md
CHANGED
package/README.md
CHANGED
|
@@ -222,11 +222,11 @@ validate or strip extra properties from the response from the API.
|
|
|
222
222
|
|
|
223
223
|
### Customizing the fetch client
|
|
224
224
|
|
|
225
|
-
By default, this library uses `
|
|
225
|
+
By default, this library uses `globalThis.fetch` in modern Node.js, falls back to `node-fetch`
|
|
226
|
+
in older Node.js environments, and expects a global `fetch` function in other runtimes.
|
|
226
227
|
|
|
227
|
-
If you would
|
|
228
|
-
|
|
229
|
-
add the following import before your first import `from "Browserbase"`:
|
|
228
|
+
If you would like to force the web-standard fetch shim, add the following import before your first
|
|
229
|
+
import `from "Browserbase"`:
|
|
230
230
|
|
|
231
231
|
```ts
|
|
232
232
|
// Tell TypeScript and the package to use the global web fetch instead of node-fetch.
|
|
@@ -235,7 +235,7 @@ import '@browserbasehq/sdk/shims/web';
|
|
|
235
235
|
import Browserbase from '@browserbasehq/sdk';
|
|
236
236
|
```
|
|
237
237
|
|
|
238
|
-
To
|
|
238
|
+
To force the legacy Node.js shim, add `import "@browserbasehq/sdk/shims/node"` (which does import polyfills).
|
|
239
239
|
This can also be useful if you are getting the wrong TypeScript types for `Response` ([more details](https://github.com/browserbase/sdk-node/tree/main/src/_shims#readme)).
|
|
240
240
|
|
|
241
241
|
### Logging and middleware
|
|
@@ -262,9 +262,13 @@ This is intended for debugging purposes only and may change in the future withou
|
|
|
262
262
|
|
|
263
263
|
### Configuring an HTTP(S) Agent (e.g., for proxies)
|
|
264
264
|
|
|
265
|
-
By default,
|
|
265
|
+
By default, modern Node.js uses `globalThis.fetch` and no node:http Agent is attached. In older
|
|
266
|
+
Node.js environments, or when you force the legacy Node.js shim, this library uses a stable agent
|
|
267
|
+
for all http/https requests to reuse TCP connections, eliminating many TCP & TLS handshakes.
|
|
266
268
|
|
|
267
|
-
If you would like to
|
|
269
|
+
If you would like to customize agent behavior, for example to use the API behind a proxy, you can
|
|
270
|
+
pass an `httpAgent`. In modern Node.js this uses the legacy `node-fetch` transport for that request
|
|
271
|
+
so the node:http Agent can be honored:
|
|
268
272
|
|
|
269
273
|
<!-- prettier-ignore -->
|
|
270
274
|
```ts
|
package/_shims/README.md
CHANGED
|
@@ -3,7 +3,9 @@
|
|
|
3
3
|
`@browserbasehq/sdk` supports a wide variety of runtime environments like Node.js, Deno, Bun, browsers, and various
|
|
4
4
|
edge runtimes, as well as both CommonJS (CJS) and EcmaScript Modules (ESM).
|
|
5
5
|
|
|
6
|
-
To do this, `@browserbasehq/sdk` provides shims for
|
|
6
|
+
To do this, `@browserbasehq/sdk` provides shims for using `globalThis.fetch` in modern Node.js,
|
|
7
|
+
falling back to `node-fetch` in older Node.js environments, or using the global `fetch` API built
|
|
8
|
+
into non-Node runtimes.
|
|
7
9
|
|
|
8
10
|
It uses [conditional exports](https://nodejs.org/api/packages.html#conditional-exports) to
|
|
9
11
|
automatically select the correct shims for each environment. However, conditional exports are a fairly new
|
|
@@ -33,7 +35,8 @@ All client code imports shims from `@browserbasehq/sdk/_shims/index`, which:
|
|
|
33
35
|
- re-exports the installed shims from `@browserbasehq/sdk/_shims/registry`.
|
|
34
36
|
|
|
35
37
|
`@browserbasehq/sdk/_shims/auto/runtime` exports web runtime shims.
|
|
36
|
-
If the `node` export condition is set, the export map replaces it with `@browserbasehq/sdk/_shims/auto/runtime-node
|
|
38
|
+
If the `node` export condition is set, the export map replaces it with `@browserbasehq/sdk/_shims/auto/runtime-node`,
|
|
39
|
+
which prefers native `globalThis.fetch` when available and falls back to the Node runtime shim when needed.
|
|
37
40
|
|
|
38
41
|
### How it works - Type time
|
|
39
42
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runtime-node.d.ts","sourceRoot":"","sources":["../../src/_shims/auto/runtime-node.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"runtime-node.d.ts","sourceRoot":"","sources":["../../src/_shims/auto/runtime-node.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,KAAK,KAAK,EAAE,MAAM,aAAa,CAAC;AA8BzC,wBAAgB,UAAU,IAAI,KAAK,CA2BlC"}
|
|
@@ -1,21 +1,49 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getRuntime = getRuntime;
|
|
17
4
|
/**
|
|
18
5
|
* Disclaimer: modules in _shims aren't intended to be imported by SDK users.
|
|
19
6
|
*/
|
|
20
|
-
|
|
7
|
+
const node_stream_1 = require("node:stream");
|
|
8
|
+
const node_runtime_1 = require("../node-runtime.js");
|
|
9
|
+
function usesNodeFetchOnlyFeatures(init) {
|
|
10
|
+
if (!init)
|
|
11
|
+
return false;
|
|
12
|
+
// Node's native fetch does not use node:http Agent instances. Preserve
|
|
13
|
+
// historical behavior for callers who explicitly configure httpAgent.
|
|
14
|
+
return Boolean(init.agent);
|
|
15
|
+
}
|
|
16
|
+
function buildNativeFetchOptions(init) {
|
|
17
|
+
if (!init)
|
|
18
|
+
return init;
|
|
19
|
+
const { agent: _agent, ...fetchInit } = init;
|
|
20
|
+
// Node's native fetch requires `duplex: 'half'` when the body is a stream.
|
|
21
|
+
const body = fetchInit.body;
|
|
22
|
+
if (body instanceof node_stream_1.Readable || typeof body?.pipe === 'function') {
|
|
23
|
+
return { duplex: 'half', ...fetchInit };
|
|
24
|
+
}
|
|
25
|
+
return fetchInit;
|
|
26
|
+
}
|
|
27
|
+
function getRuntime() {
|
|
28
|
+
const nodeRuntime = (0, node_runtime_1.getRuntime)();
|
|
29
|
+
const nativeFetch = globalThis.fetch;
|
|
30
|
+
if (typeof nativeFetch !== 'function') {
|
|
31
|
+
return nodeRuntime;
|
|
32
|
+
}
|
|
33
|
+
return {
|
|
34
|
+
...nodeRuntime,
|
|
35
|
+
fetch: (url, init) => {
|
|
36
|
+
if (usesNodeFetchOnlyFeatures(init)) {
|
|
37
|
+
return nodeRuntime.fetch(url, init);
|
|
38
|
+
}
|
|
39
|
+
return nativeFetch.call(undefined, url, buildNativeFetchOptions(init));
|
|
40
|
+
},
|
|
41
|
+
Request: typeof globalThis.Request !== 'undefined' ? globalThis.Request : nodeRuntime.Request,
|
|
42
|
+
Response: typeof globalThis.Response !== 'undefined' ?
|
|
43
|
+
globalThis.Response
|
|
44
|
+
: nodeRuntime.Response,
|
|
45
|
+
Headers: typeof globalThis.Headers !== 'undefined' ? globalThis.Headers : nodeRuntime.Headers,
|
|
46
|
+
getDefaultAgent: () => undefined,
|
|
47
|
+
};
|
|
48
|
+
}
|
|
21
49
|
//# sourceMappingURL=runtime-node.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runtime-node.js","sourceRoot":"","sources":["../../src/_shims/auto/runtime-node.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"runtime-node.js","sourceRoot":"","sources":["../../src/_shims/auto/runtime-node.ts"],"names":[],"mappings":";;AAmCA,gCA2BC;AA9DD;;GAEG;AACH,6CAAuC;AACvC,qDAA+D;AAS/D,SAAS,yBAAyB,CAAC,IAAoC;IACrE,IAAI,CAAC,IAAI;QAAE,OAAO,KAAK,CAAC;IAExB,uEAAuE;IACvE,sEAAsE;IACtE,OAAO,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;AAC7B,CAAC;AAED,SAAS,uBAAuB,CAAC,IAAoC;IACnE,IAAI,CAAC,IAAI;QAAE,OAAO,IAAI,CAAC;IAEvB,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,SAAS,EAAE,GAAG,IAAI,CAAC;IAE7C,2EAA2E;IAC3E,MAAM,IAAI,GAAG,SAAS,CAAC,IAAI,CAAC;IAC5B,IAAI,IAAI,YAAY,sBAAQ,IAAI,OAAQ,IAAY,EAAE,IAAI,KAAK,UAAU,EAAE,CAAC;QAC1E,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,SAAS,EAAE,CAAC;IAC1C,CAAC;IAED,OAAO,SAAS,CAAC;AACnB,CAAC;AAED,SAAgB,UAAU;IACxB,MAAM,WAAW,GAAG,IAAA,yBAAc,GAAE,CAAC;IACrC,MAAM,WAAW,GAAI,UAAkB,CAAC,KAAK,CAAC;IAE9C,IAAI,OAAO,WAAW,KAAK,UAAU,EAAE,CAAC;QACtC,OAAO,WAAW,CAAC;IACrB,CAAC;IAED,OAAO;QACL,GAAG,WAAW;QACd,KAAK,EAAE,CAAC,GAAY,EAAE,IAAyB,EAAE,EAAE;YACjD,IAAI,yBAAyB,CAAC,IAAI,CAAC,EAAE,CAAC;gBACpC,OAAO,WAAW,CAAC,KAAK,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC;YACtC,CAAC;YAED,OAAO,WAAW,CAAC,IAAI,CAAC,SAAS,EAAE,GAAG,EAAE,uBAAuB,CAAC,IAAI,CAAC,CAAC,CAAC;QACzE,CAAC;QACD,OAAO,EACL,OAAQ,UAAkB,CAAC,OAAO,KAAK,WAAW,CAAC,CAAC,CAAE,UAAkB,CAAC,OAAO,CAAC,CAAC,CAAC,WAAW,CAAC,OAAO;QACxG,QAAQ,EACN,OAAQ,UAAkB,CAAC,QAAQ,KAAK,WAAW,CAAC,CAAC;YAClD,UAAkB,CAAC,QAAQ;YAC9B,CAAC,CAAC,WAAW,CAAC,QAAQ;QACxB,OAAO,EACL,OAAQ,UAAkB,CAAC,OAAO,KAAK,WAAW,CAAC,CAAC,CAAE,UAAkB,CAAC,OAAO,CAAC,CAAC,CAAC,WAAW,CAAC,OAAO;QACxG,eAAe,EAAE,GAAG,EAAE,CAAC,SAAS;KACjC,CAAC;AACJ,CAAC"}
|
|
@@ -1,2 +1,43 @@
|
|
|
1
|
-
|
|
1
|
+
import { Readable } from 'node:stream';
|
|
2
|
+
import { getRuntime as getNodeRuntime } from "../node-runtime.mjs";
|
|
3
|
+
function usesNodeFetchOnlyFeatures(init) {
|
|
4
|
+
if (!init)
|
|
5
|
+
return false;
|
|
6
|
+
// Node's native fetch does not use node:http Agent instances. Preserve
|
|
7
|
+
// historical behavior for callers who explicitly configure httpAgent.
|
|
8
|
+
return Boolean(init.agent);
|
|
9
|
+
}
|
|
10
|
+
function buildNativeFetchOptions(init) {
|
|
11
|
+
if (!init)
|
|
12
|
+
return init;
|
|
13
|
+
const { agent: _agent, ...fetchInit } = init;
|
|
14
|
+
// Node's native fetch requires `duplex: 'half'` when the body is a stream.
|
|
15
|
+
const body = fetchInit.body;
|
|
16
|
+
if (body instanceof Readable || typeof body?.pipe === 'function') {
|
|
17
|
+
return { duplex: 'half', ...fetchInit };
|
|
18
|
+
}
|
|
19
|
+
return fetchInit;
|
|
20
|
+
}
|
|
21
|
+
export function getRuntime() {
|
|
22
|
+
const nodeRuntime = getNodeRuntime();
|
|
23
|
+
const nativeFetch = globalThis.fetch;
|
|
24
|
+
if (typeof nativeFetch !== 'function') {
|
|
25
|
+
return nodeRuntime;
|
|
26
|
+
}
|
|
27
|
+
return {
|
|
28
|
+
...nodeRuntime,
|
|
29
|
+
fetch: (url, init) => {
|
|
30
|
+
if (usesNodeFetchOnlyFeatures(init)) {
|
|
31
|
+
return nodeRuntime.fetch(url, init);
|
|
32
|
+
}
|
|
33
|
+
return nativeFetch.call(undefined, url, buildNativeFetchOptions(init));
|
|
34
|
+
},
|
|
35
|
+
Request: typeof globalThis.Request !== 'undefined' ? globalThis.Request : nodeRuntime.Request,
|
|
36
|
+
Response: typeof globalThis.Response !== 'undefined' ?
|
|
37
|
+
globalThis.Response
|
|
38
|
+
: nodeRuntime.Response,
|
|
39
|
+
Headers: typeof globalThis.Headers !== 'undefined' ? globalThis.Headers : nodeRuntime.Headers,
|
|
40
|
+
getDefaultAgent: () => undefined,
|
|
41
|
+
};
|
|
42
|
+
}
|
|
2
43
|
//# sourceMappingURL=runtime-node.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runtime-node.mjs","sourceRoot":"","sources":["../../src/_shims/auto/runtime-node.ts"],"names":[],"mappings":""}
|
|
1
|
+
{"version":3,"file":"runtime-node.mjs","sourceRoot":"","sources":["../../src/_shims/auto/runtime-node.ts"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OAAQ,UAAkB,CAAC,OAAO,KAAK,WAAW,CAAC,CAAC,CAAE,UAAkB,CAAC,OAAO,CAAC,CAAC,CAAC,WAAW,CAAC,OAAO;QACxG,QAAQ,EACN,OAAQ,UAAkB,CAAC,QAAQ,KAAK,WAAW,CAAC,CAAC;YAClD,UAAkB,CAAC,QAAQ;YAC9B,CAAC,CAAC,WAAW,CAAC,QAAQ;QACxB,OAAO,EACL,OAAQ,UAAkB,CAAC,OAAO,KAAK,WAAW,CAAC,CAAC,CAAE,UAAkB,CAAC,OAAO,CAAC,CAAC,CAAC,WAAW,CAAC,OAAO;QACxG,eAAe,EAAE,GAAG,EAAE,CAAC,SAAS;KACjC,CAAC;AACJ,CAAC"}
|
package/_shims/index.d.ts
CHANGED
|
@@ -18,6 +18,8 @@ export const fetch: SelectType<typeof manual.fetch, typeof auto.fetch>;
|
|
|
18
18
|
// @ts-ignore
|
|
19
19
|
export type Request = SelectType<manual.Request, auto.Request>;
|
|
20
20
|
// @ts-ignore
|
|
21
|
+
export const Request: SelectType<typeof manual.Request, typeof auto.Request>;
|
|
22
|
+
// @ts-ignore
|
|
21
23
|
export type RequestInfo = SelectType<manual.RequestInfo, auto.RequestInfo>;
|
|
22
24
|
// @ts-ignore
|
|
23
25
|
export type RequestInit = SelectType<manual.RequestInit, auto.RequestInit>;
|
|
@@ -25,6 +27,8 @@ export type RequestInit = SelectType<manual.RequestInit, auto.RequestInit>;
|
|
|
25
27
|
// @ts-ignore
|
|
26
28
|
export type Response = SelectType<manual.Response, auto.Response>;
|
|
27
29
|
// @ts-ignore
|
|
30
|
+
export const Response: SelectType<typeof manual.Response, typeof auto.Response>;
|
|
31
|
+
// @ts-ignore
|
|
28
32
|
export type ResponseInit = SelectType<manual.ResponseInit, auto.ResponseInit>;
|
|
29
33
|
// @ts-ignore
|
|
30
34
|
export type ResponseType = SelectType<manual.ResponseType, auto.ResponseType>;
|
package/_shims/node-types.d.ts
CHANGED
|
@@ -12,14 +12,17 @@ export { ReadableStream } from 'node:stream/web';
|
|
|
12
12
|
export const fetch: typeof nf.default;
|
|
13
13
|
|
|
14
14
|
export type Request = nf.Request;
|
|
15
|
+
export const Request: typeof nf.Request;
|
|
15
16
|
export type RequestInfo = nf.RequestInfo;
|
|
16
17
|
export type RequestInit = nf.RequestInit;
|
|
17
18
|
|
|
18
19
|
export type Response = nf.Response;
|
|
20
|
+
export const Response: typeof nf.Response;
|
|
19
21
|
export type ResponseInit = nf.ResponseInit;
|
|
20
22
|
export type ResponseType = nf.ResponseType;
|
|
21
23
|
export type BodyInit = nf.BodyInit;
|
|
22
24
|
export type Headers = nf.Headers;
|
|
25
|
+
export const Headers: typeof nf.Headers;
|
|
23
26
|
export type HeadersInit = nf.HeadersInit;
|
|
24
27
|
|
|
25
28
|
type EndingType = 'native' | 'transparent';
|
package/index.d.mts
CHANGED
|
@@ -34,15 +34,17 @@ export interface ClientOptions {
|
|
|
34
34
|
/**
|
|
35
35
|
* An HTTP agent used to manage HTTP(S) connections.
|
|
36
36
|
*
|
|
37
|
-
* If
|
|
38
|
-
*
|
|
37
|
+
* If provided in Node.js, requests use the legacy `node-fetch` transport so the agent can be
|
|
38
|
+
* honored. The default modern Node.js transport uses `globalThis.fetch` and does not attach
|
|
39
|
+
* a node:http Agent.
|
|
39
40
|
*/
|
|
40
41
|
httpAgent?: Agent | undefined;
|
|
41
42
|
/**
|
|
42
43
|
* Specify a custom `fetch` function implementation.
|
|
43
44
|
*
|
|
44
|
-
* If not provided, we use `
|
|
45
|
-
*
|
|
45
|
+
* If not provided, we use `globalThis.fetch` in Node.js when available, fall back to
|
|
46
|
+
* `node-fetch` in older Node.js environments, and otherwise expect that `fetch` is defined
|
|
47
|
+
* globally.
|
|
46
48
|
*/
|
|
47
49
|
fetch?: Core.Fetch | undefined;
|
|
48
50
|
/**
|
package/index.d.ts
CHANGED
|
@@ -34,15 +34,17 @@ export interface ClientOptions {
|
|
|
34
34
|
/**
|
|
35
35
|
* An HTTP agent used to manage HTTP(S) connections.
|
|
36
36
|
*
|
|
37
|
-
* If
|
|
38
|
-
*
|
|
37
|
+
* If provided in Node.js, requests use the legacy `node-fetch` transport so the agent can be
|
|
38
|
+
* honored. The default modern Node.js transport uses `globalThis.fetch` and does not attach
|
|
39
|
+
* a node:http Agent.
|
|
39
40
|
*/
|
|
40
41
|
httpAgent?: Agent | undefined;
|
|
41
42
|
/**
|
|
42
43
|
* Specify a custom `fetch` function implementation.
|
|
43
44
|
*
|
|
44
|
-
* If not provided, we use `
|
|
45
|
-
*
|
|
45
|
+
* If not provided, we use `globalThis.fetch` in Node.js when available, fall back to
|
|
46
|
+
* `node-fetch` in older Node.js environments, and otherwise expect that `fetch` is defined
|
|
47
|
+
* globally.
|
|
46
48
|
*/
|
|
47
49
|
fetch?: Core.Fetch | undefined;
|
|
48
50
|
/**
|
package/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["src/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,KAAK,EAAE,MAAM,gBAAgB,CAAC;AAC5C,OAAO,KAAK,IAAI,MAAM,QAAQ,CAAC;AAC/B,OAAO,KAAK,MAAM,MAAM,SAAS,CAAC;AAClC,OAAO,KAAK,OAAO,MAAM,WAAW,CAAC;AACrC,OAAO,KAAK,GAAG,MAAM,mBAAmB,CAAC;AACzC,OAAO,EACL,WAAW,EACX,uBAAuB,EACvB,uBAAuB,EACvB,YAAY,EACb,MAAM,0BAA0B,CAAC;AAClC,OAAO,EACL,OAAO,EACP,mBAAmB,EACnB,qBAAqB,EACrB,qBAAqB,EACrB,QAAQ,EACT,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,SAAS,EAAE,qBAAqB,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AACtF,OAAO,EAAE,QAAQ,EAAE,oBAAoB,EAAE,sBAAsB,EAAE,MAAM,uBAAuB,CAAC;AAC/F,OAAO,EAAE,OAAO,EAAE,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zB,MAAM,SAAS,CAAC;AAEjB,eAAe,WAAW,CAAC"}
|
package/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["src/index.ts"],"names":[],"mappings":";AAAA,sFAAsF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAGtF,gDAA+B;AAC/B,mDAAkC;AAClC,sDAAqC;AACrC,0DAAyC;AACzC,8DAKkC;AAClC,sDAM8B;AAC9B,0DAAsF;AACtF,wDAA+F;AAC/F,sDAA4F;AAC5F,kDAAgF;AAChF,+DAUuC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["src/index.ts"],"names":[],"mappings":";AAAA,sFAAsF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAGtF,gDAA+B;AAC/B,mDAAkC;AAClC,sDAAqC;AACrC,0DAAyC;AACzC,8DAKkC;AAClC,sDAM8B;AAC9B,0DAAsF;AACtF,wDAA+F;AAC/F,sDAA4F;AAC5F,kDAAgF;AAChF,+DAUuC;AAqEvC;;GAEG;AACH,MAAa,WAAY,SAAQ,IAAI,CAAC,SAAS;IAK7C;;;;;;;;;;;OAWG;IACH,YAAY,EACV,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC,sBAAsB,CAAC,EAC9C,MAAM,GAAG,IAAI,CAAC,OAAO,CAAC,qBAAqB,CAAC,EAC5C,GAAG,IAAI,KACU,EAAE;QACnB,IAAI,MAAM,KAAK,SAAS,EAAE,CAAC;YACzB,MAAM,IAAI,MAAM,CAAC,gBAAgB,CAC/B,mMAAmM,CACpM,CAAC;QACJ,CAAC;QAED,MAAM,OAAO,GAAkB;YAC7B,MAAM;YACN,GAAG,IAAI;YACP,OAAO,EAAE,OAAO,IAAI,6BAA6B;SAClD,CAAC;QAEF,KAAK,CAAC;YACJ,OAAO,EAAE,OAAO,CAAC,OAAQ;YACzB,iBAAiB,EAAE,OAAO,CAAC,CAAC,CAAC,OA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CAAwB,GAAG,MAAM,CAAC,wBAAwB,AAAlC,CAAmC;AAE3D,kBAAM,GAAG,OAAO,CAAC,MAAM,AAAjB,CAAkB;AACxB,wBAAY,GAAG,OAAO,CAAC,YAAY,AAAvB,CAAwB;AAG7C,WAAW,CAAC,YAAY,GAAG,YAAY,CAAC;AACxC,WAAW,CAAC,QAAQ,GAAG,QAAQ,CAAC;AAChC,WAAW,CAAC,UAAU,GAAG,UAAU,CAAC;AACpC,WAAW,CAAC,QAAQ,GAAG,QAAQ,CAAC;AAChC,WAAW,CAAC,QAAQ,GAAG,QAAQ,CAAC;AAChC,WAAW,CAAC,MAAM,GAAG,MAAM,CAAC;AAC5B,WAAW,CAAC,QAAQ,GAAG,QAAQ,CAAC;OA0DzB,EAAE,MAAM,EAAE,YAAY,EAAE;OACxB,EACL,gBAAgB,EAChB,QAAQ,EACR,kBAAkB,EAClB,yBAAyB,EACzB,iBAAiB,EACjB,aAAa,EACb,aAAa,EACb,cAAc,EACd,eAAe,EACf,mBAAmB,EACnB,mBAAmB,EACnB,qBAAqB,EACrB,wBAAwB,GACzB;AAED,eAAe,WAAW,CAAC"}
|
package/package.json
CHANGED
package/src/_shims/README.md
CHANGED
|
@@ -3,7 +3,9 @@
|
|
|
3
3
|
`@browserbasehq/sdk` supports a wide variety of runtime environments like Node.js, Deno, Bun, browsers, and various
|
|
4
4
|
edge runtimes, as well as both CommonJS (CJS) and EcmaScript Modules (ESM).
|
|
5
5
|
|
|
6
|
-
To do this, `@browserbasehq/sdk` provides shims for
|
|
6
|
+
To do this, `@browserbasehq/sdk` provides shims for using `globalThis.fetch` in modern Node.js,
|
|
7
|
+
falling back to `node-fetch` in older Node.js environments, or using the global `fetch` API built
|
|
8
|
+
into non-Node runtimes.
|
|
7
9
|
|
|
8
10
|
It uses [conditional exports](https://nodejs.org/api/packages.html#conditional-exports) to
|
|
9
11
|
automatically select the correct shims for each environment. However, conditional exports are a fairly new
|
|
@@ -33,7 +35,8 @@ All client code imports shims from `@browserbasehq/sdk/_shims/index`, which:
|
|
|
33
35
|
- re-exports the installed shims from `@browserbasehq/sdk/_shims/registry`.
|
|
34
36
|
|
|
35
37
|
`@browserbasehq/sdk/_shims/auto/runtime` exports web runtime shims.
|
|
36
|
-
If the `node` export condition is set, the export map replaces it with `@browserbasehq/sdk/_shims/auto/runtime-node
|
|
38
|
+
If the `node` export condition is set, the export map replaces it with `@browserbasehq/sdk/_shims/auto/runtime-node`,
|
|
39
|
+
which prefers native `globalThis.fetch` when available and falls back to the Node runtime shim when needed.
|
|
37
40
|
|
|
38
41
|
### How it works - Type time
|
|
39
42
|
|
|
@@ -1,4 +1,63 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Disclaimer: modules in _shims aren't intended to be imported by SDK users.
|
|
3
3
|
*/
|
|
4
|
-
|
|
4
|
+
import { Readable } from 'node:stream';
|
|
5
|
+
import { getRuntime as getNodeRuntime } from '../node-runtime';
|
|
6
|
+
import { type Shims } from '../registry';
|
|
7
|
+
|
|
8
|
+
type FetchInitWithAgent = {
|
|
9
|
+
agent?: unknown;
|
|
10
|
+
body?: unknown;
|
|
11
|
+
[key: string]: unknown;
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
function usesNodeFetchOnlyFeatures(init: FetchInitWithAgent | undefined): boolean {
|
|
15
|
+
if (!init) return false;
|
|
16
|
+
|
|
17
|
+
// Node's native fetch does not use node:http Agent instances. Preserve
|
|
18
|
+
// historical behavior for callers who explicitly configure httpAgent.
|
|
19
|
+
return Boolean(init.agent);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
function buildNativeFetchOptions(init: FetchInitWithAgent | undefined): FetchInitWithAgent | undefined {
|
|
23
|
+
if (!init) return init;
|
|
24
|
+
|
|
25
|
+
const { agent: _agent, ...fetchInit } = init;
|
|
26
|
+
|
|
27
|
+
// Node's native fetch requires `duplex: 'half'` when the body is a stream.
|
|
28
|
+
const body = fetchInit.body;
|
|
29
|
+
if (body instanceof Readable || typeof (body as any)?.pipe === 'function') {
|
|
30
|
+
return { duplex: 'half', ...fetchInit };
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
return fetchInit;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export function getRuntime(): Shims {
|
|
37
|
+
const nodeRuntime = getNodeRuntime();
|
|
38
|
+
const nativeFetch = (globalThis as any).fetch;
|
|
39
|
+
|
|
40
|
+
if (typeof nativeFetch !== 'function') {
|
|
41
|
+
return nodeRuntime;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
return {
|
|
45
|
+
...nodeRuntime,
|
|
46
|
+
fetch: (url: unknown, init?: FetchInitWithAgent) => {
|
|
47
|
+
if (usesNodeFetchOnlyFeatures(init)) {
|
|
48
|
+
return nodeRuntime.fetch(url, init);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
return nativeFetch.call(undefined, url, buildNativeFetchOptions(init));
|
|
52
|
+
},
|
|
53
|
+
Request:
|
|
54
|
+
typeof (globalThis as any).Request !== 'undefined' ? (globalThis as any).Request : nodeRuntime.Request,
|
|
55
|
+
Response:
|
|
56
|
+
typeof (globalThis as any).Response !== 'undefined' ?
|
|
57
|
+
(globalThis as any).Response
|
|
58
|
+
: nodeRuntime.Response,
|
|
59
|
+
Headers:
|
|
60
|
+
typeof (globalThis as any).Headers !== 'undefined' ? (globalThis as any).Headers : nodeRuntime.Headers,
|
|
61
|
+
getDefaultAgent: () => undefined,
|
|
62
|
+
};
|
|
63
|
+
}
|
package/src/_shims/index.d.ts
CHANGED
|
@@ -18,6 +18,8 @@ export const fetch: SelectType<typeof manual.fetch, typeof auto.fetch>;
|
|
|
18
18
|
// @ts-ignore
|
|
19
19
|
export type Request = SelectType<manual.Request, auto.Request>;
|
|
20
20
|
// @ts-ignore
|
|
21
|
+
export const Request: SelectType<typeof manual.Request, typeof auto.Request>;
|
|
22
|
+
// @ts-ignore
|
|
21
23
|
export type RequestInfo = SelectType<manual.RequestInfo, auto.RequestInfo>;
|
|
22
24
|
// @ts-ignore
|
|
23
25
|
export type RequestInit = SelectType<manual.RequestInit, auto.RequestInit>;
|
|
@@ -25,6 +27,8 @@ export type RequestInit = SelectType<manual.RequestInit, auto.RequestInit>;
|
|
|
25
27
|
// @ts-ignore
|
|
26
28
|
export type Response = SelectType<manual.Response, auto.Response>;
|
|
27
29
|
// @ts-ignore
|
|
30
|
+
export const Response: SelectType<typeof manual.Response, typeof auto.Response>;
|
|
31
|
+
// @ts-ignore
|
|
28
32
|
export type ResponseInit = SelectType<manual.ResponseInit, auto.ResponseInit>;
|
|
29
33
|
// @ts-ignore
|
|
30
34
|
export type ResponseType = SelectType<manual.ResponseType, auto.ResponseType>;
|
|
@@ -12,14 +12,17 @@ export { ReadableStream } from 'node:stream/web';
|
|
|
12
12
|
export const fetch: typeof nf.default;
|
|
13
13
|
|
|
14
14
|
export type Request = nf.Request;
|
|
15
|
+
export const Request: typeof nf.Request;
|
|
15
16
|
export type RequestInfo = nf.RequestInfo;
|
|
16
17
|
export type RequestInit = nf.RequestInit;
|
|
17
18
|
|
|
18
19
|
export type Response = nf.Response;
|
|
20
|
+
export const Response: typeof nf.Response;
|
|
19
21
|
export type ResponseInit = nf.ResponseInit;
|
|
20
22
|
export type ResponseType = nf.ResponseType;
|
|
21
23
|
export type BodyInit = nf.BodyInit;
|
|
22
24
|
export type Headers = nf.Headers;
|
|
25
|
+
export const Headers: typeof nf.Headers;
|
|
23
26
|
export type HeadersInit = nf.HeadersInit;
|
|
24
27
|
|
|
25
28
|
type EndingType = 'native' | 'transparent';
|
package/src/index.ts
CHANGED
|
@@ -61,16 +61,18 @@ export interface ClientOptions {
|
|
|
61
61
|
/**
|
|
62
62
|
* An HTTP agent used to manage HTTP(S) connections.
|
|
63
63
|
*
|
|
64
|
-
* If
|
|
65
|
-
*
|
|
64
|
+
* If provided in Node.js, requests use the legacy `node-fetch` transport so the agent can be
|
|
65
|
+
* honored. The default modern Node.js transport uses `globalThis.fetch` and does not attach
|
|
66
|
+
* a node:http Agent.
|
|
66
67
|
*/
|
|
67
68
|
httpAgent?: Agent | undefined;
|
|
68
69
|
|
|
69
70
|
/**
|
|
70
71
|
* Specify a custom `fetch` function implementation.
|
|
71
72
|
*
|
|
72
|
-
* If not provided, we use `
|
|
73
|
-
*
|
|
73
|
+
* If not provided, we use `globalThis.fetch` in Node.js when available, fall back to
|
|
74
|
+
* `node-fetch` in older Node.js environments, and otherwise expect that `fetch` is defined
|
|
75
|
+
* globally.
|
|
74
76
|
*/
|
|
75
77
|
fetch?: Core.Fetch | undefined;
|
|
76
78
|
|
package/src/version.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const VERSION = '2.14.
|
|
1
|
+
export const VERSION = '2.14.1'; // x-release-please-version
|
package/version.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const VERSION = "2.14.
|
|
1
|
+
export declare const VERSION = "2.14.1";
|
|
2
2
|
//# sourceMappingURL=version.d.ts.map
|
package/version.js
CHANGED
package/version.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export const VERSION = '2.14.
|
|
1
|
+
export const VERSION = '2.14.1'; // x-release-please-version
|
|
2
2
|
//# sourceMappingURL=version.mjs.map
|