@supabase/storage-js 2.78.0 → 2.78.1-canary.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.
Files changed (39) hide show
  1. package/README.md +9 -0
  2. package/dist/main/lib/helpers.d.ts +1 -1
  3. package/dist/main/lib/helpers.d.ts.map +1 -1
  4. package/dist/main/lib/helpers.js +4 -16
  5. package/dist/main/lib/helpers.js.map +1 -1
  6. package/dist/main/lib/vectors/helpers.d.ts +3 -6
  7. package/dist/main/lib/vectors/helpers.d.ts.map +1 -1
  8. package/dist/main/lib/vectors/helpers.js +6 -21
  9. package/dist/main/lib/vectors/helpers.js.map +1 -1
  10. package/dist/main/lib/version.d.ts +1 -1
  11. package/dist/main/lib/version.d.ts.map +1 -1
  12. package/dist/main/lib/version.js +1 -1
  13. package/dist/main/lib/version.js.map +1 -1
  14. package/dist/main/packages/StorageFileApi.d.ts.map +1 -1
  15. package/dist/main/packages/StorageFileApi.js +12 -2
  16. package/dist/main/packages/StorageFileApi.js.map +1 -1
  17. package/dist/module/lib/helpers.d.ts +1 -1
  18. package/dist/module/lib/helpers.d.ts.map +1 -1
  19. package/dist/module/lib/helpers.js +4 -16
  20. package/dist/module/lib/helpers.js.map +1 -1
  21. package/dist/module/lib/vectors/helpers.d.ts +3 -6
  22. package/dist/module/lib/vectors/helpers.d.ts.map +1 -1
  23. package/dist/module/lib/vectors/helpers.js +6 -21
  24. package/dist/module/lib/vectors/helpers.js.map +1 -1
  25. package/dist/module/lib/version.d.ts +1 -1
  26. package/dist/module/lib/version.d.ts.map +1 -1
  27. package/dist/module/lib/version.js +1 -1
  28. package/dist/module/lib/version.js.map +1 -1
  29. package/dist/module/packages/StorageFileApi.d.ts.map +1 -1
  30. package/dist/module/packages/StorageFileApi.js +12 -2
  31. package/dist/module/packages/StorageFileApi.js.map +1 -1
  32. package/dist/tsconfig.module.tsbuildinfo +1 -1
  33. package/dist/tsconfig.tsbuildinfo +1 -1
  34. package/dist/umd/supabase.js +1 -1
  35. package/package.json +4 -2
  36. package/src/lib/helpers.ts +3 -14
  37. package/src/lib/vectors/helpers.ts +5 -19
  38. package/src/lib/version.ts +1 -1
  39. package/src/packages/StorageFileApi.ts +15 -2
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@supabase/storage-js",
3
- "version": "2.78.0",
3
+ "version": "2.78.1-canary.1",
4
4
  "description": "Isomorphic storage client for Supabase.",
5
5
  "keywords": [
6
6
  "javascript",
@@ -37,7 +37,6 @@
37
37
  "docs:json": "typedoc --json docs/v2/spec.json --entryPoints src/index.ts --entryPoints src/packages/* --excludePrivate --excludeExternals --excludeProtected"
38
38
  },
39
39
  "dependencies": {
40
- "@supabase/node-fetch": "2.6.15",
41
40
  "tslib": "2.8.1"
42
41
  },
43
42
  "devDependencies": {
@@ -50,5 +49,8 @@
50
49
  "unpkg": "dist/umd/supabase.js",
51
50
  "publishConfig": {
52
51
  "access": "public"
52
+ },
53
+ "engines": {
54
+ "node": ">=20.0.0"
53
55
  }
54
56
  }
@@ -1,24 +1,13 @@
1
1
  type Fetch = typeof fetch
2
2
 
3
3
  export const resolveFetch = (customFetch?: Fetch): Fetch => {
4
- let _fetch: Fetch
5
4
  if (customFetch) {
6
- _fetch = customFetch
7
- } else if (typeof fetch === 'undefined') {
8
- _fetch = (...args) =>
9
- import('@supabase/node-fetch' as any).then(({ default: fetch }) => fetch(...args))
10
- } else {
11
- _fetch = fetch
5
+ return (...args) => customFetch(...args)
12
6
  }
13
- return (...args) => _fetch(...args)
7
+ return (...args) => fetch(...args)
14
8
  }
15
9
 
16
- export const resolveResponse = async (): Promise<typeof Response> => {
17
- if (typeof Response === 'undefined') {
18
- // @ts-ignore
19
- return (await import('@supabase/node-fetch' as any)).Response
20
- }
21
-
10
+ export const resolveResponse = (): typeof Response => {
22
11
  return Response
23
12
  }
24
13
 
@@ -2,39 +2,25 @@ type Fetch = typeof fetch
2
2
 
3
3
  /**
4
4
  * Resolves the fetch implementation to use
5
- * Uses custom fetch if provided, otherwise falls back to:
6
- * - Native fetch in browser/modern environments
7
- * - @supabase/node-fetch polyfill in Node.js environments without fetch
5
+ * Uses custom fetch if provided, otherwise uses native fetch
8
6
  *
9
7
  * @param customFetch - Optional custom fetch implementation
10
8
  * @returns Resolved fetch function
11
9
  */
12
10
  export const resolveFetch = (customFetch?: Fetch): Fetch => {
13
- let _fetch: Fetch
14
11
  if (customFetch) {
15
- _fetch = customFetch
16
- } else if (typeof fetch === 'undefined') {
17
- _fetch = (...args) =>
18
- import('@supabase/node-fetch' as any).then(({ default: fetch }) => fetch(...args))
19
- } else {
20
- _fetch = fetch
12
+ return (...args) => customFetch(...args)
21
13
  }
22
- return (...args) => _fetch(...args)
14
+ return (...args) => fetch(...args)
23
15
  }
24
16
 
25
17
  /**
26
18
  * Resolves the Response constructor to use
27
- * Uses native Response in browser/modern environments
28
- * Falls back to @supabase/node-fetch polyfill in Node.js environments
19
+ * Returns native Response constructor
29
20
  *
30
21
  * @returns Response constructor
31
22
  */
32
- export const resolveResponse = async (): Promise<typeof Response> => {
33
- if (typeof Response === 'undefined') {
34
- // @ts-ignore
35
- return (await import('@supabase/node-fetch' as any)).Response
36
- }
37
-
23
+ export const resolveResponse = (): typeof Response => {
38
24
  return Response
39
25
  }
40
26
 
@@ -4,4 +4,4 @@
4
4
  // - Debugging and support (identifying which version is running)
5
5
  // - Telemetry and logging (version reporting in errors/analytics)
6
6
  // - Ensuring build artifacts match the published package version
7
- export const version = '2.78.0'
7
+ export const version = '2.78.1-canary.1'
@@ -110,8 +110,11 @@ export default class StorageFileApi {
110
110
  body.append('', fileBody)
111
111
  } else if (typeof FormData !== 'undefined' && fileBody instanceof FormData) {
112
112
  body = fileBody
113
- body.append('cacheControl', options.cacheControl as string)
114
- if (metadata) {
113
+ // Only append if not already present
114
+ if (!body.has('cacheControl')) {
115
+ body.append('cacheControl', options.cacheControl as string)
116
+ }
117
+ if (metadata && !body.has('metadata')) {
115
118
  body.append('metadata', this.encodeMetadata(metadata))
116
119
  }
117
120
  } else {
@@ -122,6 +125,16 @@ export default class StorageFileApi {
122
125
  if (metadata) {
123
126
  headers['x-metadata'] = this.toBase64(this.encodeMetadata(metadata))
124
127
  }
128
+
129
+ // Node.js streams require duplex option for fetch in Node 20+
130
+ // Check for both web ReadableStream and Node.js streams
131
+ const isStream =
132
+ (typeof ReadableStream !== 'undefined' && body instanceof ReadableStream) ||
133
+ (body && typeof body === 'object' && 'pipe' in body && typeof body.pipe === 'function')
134
+
135
+ if (isStream && !options.duplex) {
136
+ options.duplex = 'half'
137
+ }
125
138
  }
126
139
 
127
140
  if (fileOptions?.headers) {