forked from transitive-bullshit/agentic
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: move puppeteer automation into main lib; update docs
- Loading branch information
1 parent
c1634b0
commit 1d621d0
Showing
8 changed files
with
129 additions
and
103 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,13 @@ | ||
/// <reference lib="dom" /> | ||
|
||
let _undici: any | ||
|
||
// Use `undici` for node.js 16 and 17 | ||
// Use `fetch` for node.js >= 18 | ||
// Use `fetch` for all other environments, including browsers | ||
// NOTE: The top-level await is removed in a `postbuild` npm script for the | ||
// browser build | ||
const fetch = | ||
globalThis.fetch ?? | ||
async function undiciFetchWrapper( | ||
...args: Parameters<typeof globalThis.fetch> | ||
): Promise<Response> { | ||
if (!_undici) { | ||
_undici = await import('undici') | ||
} | ||
|
||
if (typeof _undici?.fetch !== 'function') { | ||
throw new Error( | ||
'Invalid undici installation; please make sure undici is installed correctly in your node_modules. Note that this package requires Node.js >= 16.8' | ||
) | ||
} | ||
const fetch = globalThis.fetch | ||
|
||
return _undici.fetch(...args) | ||
} | ||
if (typeof fetch !== 'function') { | ||
throw new Error( | ||
'Invalid environment: global fetch not defined; `chatgpt` requires Node.js >= 18 at the moment due to Cloudflare protections' | ||
) | ||
} | ||
|
||
export { fetch } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.