You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
> Once this package is [published to npm](https://app.stainlessapi.com/docs/guides/publish), this will become: `npm install browserbase`
19
+
17
20
## Usage
18
21
19
22
The full API of this library can be found in [api.md](api.md).
20
23
21
24
<!-- prettier-ignore -->
22
25
```js
23
-
importBrowserbasefrom'@browserbasehq/sdk';
26
+
importBrowserbasefrom'browserbase';
24
27
25
28
constclient=newBrowserbase({
26
29
apiKey:process.env['BROWSERBASE_API_KEY'], // This is the default and can be omitted
@@ -41,7 +44,7 @@ This library includes TypeScript definitions for all request params and response
41
44
42
45
<!-- prettier-ignore -->
43
46
```ts
44
-
importBrowserbasefrom'@browserbasehq/sdk';
47
+
importBrowserbasefrom'browserbase';
45
48
46
49
const client =newBrowserbase({
47
50
apiKey: process.env['BROWSERBASE_API_KEY'], // This is the default and can be omitted
@@ -215,11 +218,11 @@ add the following import before your first import `from "Browserbase"`:
215
218
```ts
216
219
// Tell TypeScript and the package to use the global web fetch instead of node-fetch.
217
220
// Note, despite the name, this does not add any polyfills, but expects them to be provided if needed.
218
-
import'@browserbasehq/sdk/shims/web';
219
-
importBrowserbasefrom'@browserbasehq/sdk';
221
+
import'browserbase/shims/web';
222
+
importBrowserbasefrom'browserbase';
220
223
```
221
224
222
-
To do the inverse, add `import "@browserbasehq/sdk/shims/node"` (which does import polyfills).
225
+
To do the inverse, add `import "browserbase/shims/node"` (which does import polyfills).
223
226
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)).
224
227
225
228
### Logging and middleware
@@ -229,7 +232,7 @@ which can be used to inspect or alter the `Request` or `Response` before/after e
`@browserbasehq/sdk` supports a wide variety of runtime environments like Node.js, Deno, Bun, browsers, and various
3
+
`browserbase` 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 either using `node-fetch` when in Node (because `fetch` is still experimental there) or the global `fetch` API built into the environment when not in Node.
6
+
To do this, `browserbase` provides shims for either using `node-fetch` when in Node (because `fetch` is still experimental there) or the global `fetch` API built into the environment when not in Node.
7
7
8
8
It uses [conditional exports](https://nodejs.org/api/packages.html#conditional-exports) to
9
9
automatically select the correct shims for each environment. However, conditional exports are a fairly new
@@ -15,32 +15,32 @@ getting the wrong raw `Response` type from `.asResponse()`, for example.
15
15
16
16
The user can work around these issues by manually importing one of:
17
17
18
-
-`import '@browserbasehq/sdk/shims/node'`
19
-
-`import '@browserbasehq/sdk/shims/web'`
18
+
-`import 'browserbase/shims/node'`
19
+
-`import 'browserbase/shims/web'`
20
20
21
21
All of the code here in `_shims` handles selecting the automatic default shims or manual overrides.
22
22
23
23
### How it works - Runtime
24
24
25
-
Runtime shims get installed by calling `setShims` exported by `@browserbasehq/sdk/_shims/registry`.
25
+
Runtime shims get installed by calling `setShims` exported by `browserbase/_shims/registry`.
26
26
27
-
Manually importing `@browserbasehq/sdk/shims/node` or `@browserbasehq/sdk/shims/web`, calls `setShims` with the respective runtime shims.
27
+
Manually importing `browserbase/shims/node` or `browserbase/shims/web`, calls `setShims` with the respective runtime shims.
28
28
29
-
All client code imports shims from `@browserbasehq/sdk/_shims/index`, which:
29
+
All client code imports shims from `browserbase/_shims/index`, which:
30
30
31
31
- checks if shims have been set manually
32
-
- if not, calls `setShims` with the shims from `@browserbasehq/sdk/_shims/auto/runtime`
33
-
- re-exports the installed shims from `@browserbasehq/sdk/_shims/registry`.
32
+
- if not, calls `setShims` with the shims from `browserbase/_shims/auto/runtime`
33
+
- re-exports the installed shims from `browserbase/_shims/registry`.
34
34
35
-
`@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`.
35
+
`browserbase/_shims/auto/runtime` exports web runtime shims.
36
+
If the `node` export condition is set, the export map replaces it with `browserbase/_shims/auto/runtime-node`.
37
37
38
38
### How it works - Type time
39
39
40
-
All client code imports shim types from `@browserbasehq/sdk/_shims/index`, which selects the manual types from `@browserbasehq/sdk/_shims/manual-types` if they have been declared, otherwise it exports the auto types from `@browserbasehq/sdk/_shims/auto/types`.
40
+
All client code imports shim types from `browserbase/_shims/index`, which selects the manual types from `browserbase/_shims/manual-types` if they have been declared, otherwise it exports the auto types from `browserbase/_shims/auto/types`.
41
41
42
-
`@browserbasehq/sdk/_shims/manual-types` exports an empty namespace.
43
-
Manually importing `@browserbasehq/sdk/shims/node` or `@browserbasehq/sdk/shims/web` merges declarations into this empty namespace, so they get picked up by `@browserbasehq/sdk/_shims/index`.
42
+
`browserbase/_shims/manual-types` exports an empty namespace.
43
+
Manually importing `browserbase/shims/node` or `browserbase/shims/web` merges declarations into this empty namespace, so they get picked up by `browserbase/_shims/index`.
44
44
45
-
`@browserbasehq/sdk/_shims/auto/types` exports web type definitions.
46
-
If the `node` export condition is set, the export map replaces it with `@browserbasehq/sdk/_shims/auto/types-node`, though TS only picks this up if `"moduleResolution": "nodenext"` or `"moduleResolution": "bundler"`.
45
+
`browserbase/_shims/auto/types` exports web type definitions.
46
+
If the `node` export condition is set, the export map replaces it with `browserbase/_shims/auto/types-node`, though TS only picks this up if `"moduleResolution": "nodenext"` or `"moduleResolution": "bundler"`.
0 commit comments