@ai-sdk/provider-utils 5.0.44 → 5.0.46
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 +15 -0
- package/dist/index.js +26 -4
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
- package/src/detect-media-type.ts +40 -2
- package/src/fetch-with-validated-redirects.ts +5 -4
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ai-sdk/provider-utils",
|
|
3
|
-
"version": "5.0.
|
|
3
|
+
"version": "5.0.46",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
}
|
|
38
38
|
},
|
|
39
39
|
"dependencies": {
|
|
40
|
-
"@ai-sdk/provider": "4.0.
|
|
40
|
+
"@ai-sdk/provider": "4.0.18",
|
|
41
41
|
"@standard-schema/spec": "^1.1.0",
|
|
42
42
|
"@workflow/serde": "4.1.0",
|
|
43
43
|
"eventsource-parser": "^3.0.8",
|
package/src/detect-media-type.ts
CHANGED
|
@@ -49,13 +49,35 @@ const imageMediaTypeSignatures = [
|
|
|
49
49
|
{
|
|
50
50
|
mediaType: 'image/avif' as const,
|
|
51
51
|
bytesPrefix: [
|
|
52
|
-
0x00,
|
|
52
|
+
0x00,
|
|
53
|
+
0x00,
|
|
54
|
+
0x00,
|
|
55
|
+
null, // box size (variable)
|
|
56
|
+
0x66,
|
|
57
|
+
0x74,
|
|
58
|
+
0x79,
|
|
59
|
+
0x70,
|
|
60
|
+
0x61,
|
|
61
|
+
0x76,
|
|
62
|
+
0x69,
|
|
63
|
+
0x66,
|
|
53
64
|
],
|
|
54
65
|
},
|
|
55
66
|
{
|
|
56
67
|
mediaType: 'image/heic' as const,
|
|
57
68
|
bytesPrefix: [
|
|
58
|
-
0x00,
|
|
69
|
+
0x00,
|
|
70
|
+
0x00,
|
|
71
|
+
0x00,
|
|
72
|
+
null, // box size (variable)
|
|
73
|
+
0x66,
|
|
74
|
+
0x74,
|
|
75
|
+
0x79,
|
|
76
|
+
0x70,
|
|
77
|
+
0x68,
|
|
78
|
+
0x65,
|
|
79
|
+
0x69,
|
|
80
|
+
0x63,
|
|
59
81
|
],
|
|
60
82
|
},
|
|
61
83
|
] as const;
|
|
@@ -68,6 +90,22 @@ const documentMediaTypeSignatures = [
|
|
|
68
90
|
] as const;
|
|
69
91
|
|
|
70
92
|
const audioMediaTypeSignaturesWithoutMp4 = [
|
|
93
|
+
{
|
|
94
|
+
mediaType: 'audio/aac' as const,
|
|
95
|
+
bytesPrefix: [0xff, 0xf0], // MPEG-4 ADTS with CRC
|
|
96
|
+
},
|
|
97
|
+
{
|
|
98
|
+
mediaType: 'audio/aac' as const,
|
|
99
|
+
bytesPrefix: [0xff, 0xf1], // MPEG-4 ADTS without CRC
|
|
100
|
+
},
|
|
101
|
+
{
|
|
102
|
+
mediaType: 'audio/aac' as const,
|
|
103
|
+
bytesPrefix: [0xff, 0xf8], // MPEG-2 ADTS with CRC
|
|
104
|
+
},
|
|
105
|
+
{
|
|
106
|
+
mediaType: 'audio/aac' as const,
|
|
107
|
+
bytesPrefix: [0xff, 0xf9], // MPEG-2 ADTS without CRC
|
|
108
|
+
},
|
|
71
109
|
{
|
|
72
110
|
mediaType: 'audio/mpeg' as const,
|
|
73
111
|
bytesPrefix: [0xff, 0xfb],
|
|
@@ -183,10 +183,11 @@ export async function fetchWithValidatedRedirects({
|
|
|
183
183
|
|
|
184
184
|
const location = response.headers?.get('location');
|
|
185
185
|
if (REDIRECT_STATUS_CODES.has(response.status) && location) {
|
|
186
|
-
//
|
|
187
|
-
// hop.
|
|
188
|
-
//
|
|
189
|
-
|
|
186
|
+
// Start releasing the redirect response's connection before moving to
|
|
187
|
+
// the next hop. Do not wait for cancellation: when a fetch wrapper keeps
|
|
188
|
+
// an unread response clone, tee cancellation can remain pending until
|
|
189
|
+
// the cloned branch is consumed.
|
|
190
|
+
void cancelResponseBody(response);
|
|
190
191
|
const nextUrl = new URL(location, currentUrl).toString();
|
|
191
192
|
|
|
192
193
|
// Drop all caller headers except the user-agent before following a
|