Skip to content

Commit c6780dd

Browse files
stainless-app[bot]RobertCraigie
authored andcommitted
chore(internal): improve node 18 shims
1 parent 80d5daa commit c6780dd

18 files changed

+136
-74
lines changed

package.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,10 @@
4949
"resolutions": {
5050
"synckit": "0.8.8"
5151
},
52+
"browser": {
53+
"./internal/shims/getBuiltinModule.mjs": "./internal/shims/nullGetBuiltinModule.mjs",
54+
"./internal/shims/getBuiltinModule.js": "./internal/shims/nullGetBuiltinModule.js"
55+
},
5256
"imports": {
5357
"@anthropic-ai/sdk": ".",
5458
"@anthropic-ai/sdk/*": "./src/*"

scripts/build

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,6 @@ node scripts/utils/fix-index-exports.cjs
3535
cp tsconfig.dist-src.json dist/src/tsconfig.json
3636
cp src/internal/shim-types.d.ts dist/internal/shim-types.d.ts
3737
cp src/internal/shim-types.d.ts dist/internal/shim-types.d.mts
38-
mkdir -p dist/internal/shims
39-
cp src/internal/shims/*.{mjs,js,d.ts,d.mts} dist/internal/shims
4038

4139
node scripts/utils/postprocess-files.cjs
4240

src/internal/shims/crypto.node.d.mts

Lines changed: 0 additions & 1 deletion
This file was deleted.

src/internal/shims/crypto.node.d.ts

Lines changed: 0 additions & 10 deletions
This file was deleted.

src/internal/shims/crypto.node.js

Lines changed: 0 additions & 11 deletions
This file was deleted.

src/internal/shims/crypto.node.mjs

Lines changed: 0 additions & 2 deletions
This file was deleted.

src/internal/shims/crypto.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import { getBuiltinModule } from './getBuiltinModule';
2+
3+
type Crypto = {
4+
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Crypto/getRandomValues) */
5+
getRandomValues<T extends ArrayBufferView | null>(array: T): T;
6+
/**
7+
* Available only in secure contexts.
8+
*
9+
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Crypto/randomUUID)
10+
*/
11+
randomUUID?: () => string;
12+
};
13+
export let getCrypto: () => Crypto | undefined = function lazyGetCrypto() {
14+
if (getCrypto !== lazyGetCrypto) return getCrypto();
15+
const crypto: Crypto = (globalThis as any).crypto || (getBuiltinModule?.('node:crypto') as any)?.webcrypto;
16+
getCrypto = () => crypto;
17+
return crypto;
18+
};

src/internal/shims/file.node.d.mts

Lines changed: 0 additions & 1 deletion
This file was deleted.

src/internal/shims/file.node.d.ts

Lines changed: 0 additions & 20 deletions
This file was deleted.

src/internal/shims/file.node.js

Lines changed: 0 additions & 11 deletions
This file was deleted.

0 commit comments

Comments
 (0)