@ai-sdk/provider-utils 4.0.63 → 4.0.65
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 +14 -0
- package/dist/index.d.mts +13 -1
- package/dist/index.d.ts +13 -1
- package/dist/index.js +62 -3
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +59 -3
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/fetch-with-validated-redirects.ts +13 -0
- package/src/index.ts +2 -0
- package/src/stringify-with-bigint-and-cycles.ts +26 -0
- package/src/uint8-utils.ts +39 -2
package/dist/index.mjs
CHANGED
|
@@ -165,7 +165,11 @@ var { btoa, atob } = globalThis;
|
|
|
165
165
|
function convertBase64ToUint8Array(base64String) {
|
|
166
166
|
const base64Url = base64String.replace(/-/g, "+").replace(/_/g, "/");
|
|
167
167
|
const latin1string = atob(base64Url);
|
|
168
|
-
|
|
168
|
+
const bytes = new Uint8Array(latin1string.length);
|
|
169
|
+
for (let i = 0; i < latin1string.length; i++) {
|
|
170
|
+
bytes[i] = latin1string.charCodeAt(i);
|
|
171
|
+
}
|
|
172
|
+
return bytes;
|
|
169
173
|
}
|
|
170
174
|
function convertUint8ArrayToBase64(array) {
|
|
171
175
|
var _a2;
|
|
@@ -183,8 +187,30 @@ function convertUint8ArrayToBase64(array) {
|
|
|
183
187
|
}
|
|
184
188
|
return btoa(chunks.join(""));
|
|
185
189
|
}
|
|
190
|
+
var typedArrayTag = Object.getOwnPropertyDescriptor(
|
|
191
|
+
Object.getPrototypeOf(Uint8Array.prototype),
|
|
192
|
+
Symbol.toStringTag
|
|
193
|
+
).get;
|
|
194
|
+
var arrayBufferByteLength = Object.getOwnPropertyDescriptor(
|
|
195
|
+
ArrayBuffer.prototype,
|
|
196
|
+
"byteLength"
|
|
197
|
+
).get;
|
|
198
|
+
function isUint8Array(value) {
|
|
199
|
+
return ArrayBuffer.isView(value) && typedArrayTag.call(value) === "Uint8Array";
|
|
200
|
+
}
|
|
201
|
+
function isArrayBuffer(value) {
|
|
202
|
+
if (typeof value !== "object" || value === null || !("byteLength" in value)) {
|
|
203
|
+
return false;
|
|
204
|
+
}
|
|
205
|
+
try {
|
|
206
|
+
arrayBufferByteLength.call(value);
|
|
207
|
+
return true;
|
|
208
|
+
} catch (e) {
|
|
209
|
+
return false;
|
|
210
|
+
}
|
|
211
|
+
}
|
|
186
212
|
function convertToBase64(value) {
|
|
187
|
-
return value
|
|
213
|
+
return isUint8Array(value) ? convertUint8ArrayToBase64(value) : value;
|
|
188
214
|
}
|
|
189
215
|
|
|
190
216
|
// src/convert-image-model-file-to-data-uri.ts
|
|
@@ -605,6 +631,12 @@ async function fetchWithValidatedRedirects({
|
|
|
605
631
|
if (REDIRECT_STATUS_CODES.has(response.status) && location) {
|
|
606
632
|
void cancelResponseBody(response);
|
|
607
633
|
const nextUrl = new URL(location, currentUrl).toString();
|
|
634
|
+
if (new URL(currentUrl).protocol === "https:" && new URL(nextUrl).protocol === "http:") {
|
|
635
|
+
throw new DownloadError({
|
|
636
|
+
url,
|
|
637
|
+
message: "Redirect from HTTPS to HTTP was blocked"
|
|
638
|
+
});
|
|
639
|
+
}
|
|
608
640
|
if (currentHeaders !== void 0 && !isSameOrigin(nextUrl, currentUrl)) {
|
|
609
641
|
const userAgent = currentHeaders.get("user-agent");
|
|
610
642
|
currentHeaders = new Headers(
|
|
@@ -907,7 +939,7 @@ function withUserAgentSuffix(headers, ...userAgentSuffixParts) {
|
|
|
907
939
|
}
|
|
908
940
|
|
|
909
941
|
// src/version.ts
|
|
910
|
-
var VERSION = true ? "4.0.
|
|
942
|
+
var VERSION = true ? "4.0.65" : "0.0.0-test";
|
|
911
943
|
|
|
912
944
|
// src/get-from-api.ts
|
|
913
945
|
var getOriginalFetch = () => globalThis.fetch;
|
|
@@ -3565,6 +3597,27 @@ async function* executeTool({
|
|
|
3565
3597
|
import {
|
|
3566
3598
|
EventSourceParserStream as EventSourceParserStream2
|
|
3567
3599
|
} from "eventsource-parser/stream";
|
|
3600
|
+
|
|
3601
|
+
// src/stringify-with-bigint-and-cycles.ts
|
|
3602
|
+
function stringifyWithBigIntAndCycles(value) {
|
|
3603
|
+
const ancestors = [];
|
|
3604
|
+
return JSON.stringify(value, function(_key, value2) {
|
|
3605
|
+
if (typeof value2 === "bigint") {
|
|
3606
|
+
return value2.toString();
|
|
3607
|
+
}
|
|
3608
|
+
if (typeof value2 !== "object" || value2 === null) {
|
|
3609
|
+
return value2;
|
|
3610
|
+
}
|
|
3611
|
+
while (ancestors.length > 0 && ancestors.at(-1) !== this) {
|
|
3612
|
+
ancestors.pop();
|
|
3613
|
+
}
|
|
3614
|
+
if (ancestors.includes(value2)) {
|
|
3615
|
+
return "[Circular]";
|
|
3616
|
+
}
|
|
3617
|
+
ancestors.push(value2);
|
|
3618
|
+
return value2;
|
|
3619
|
+
});
|
|
3620
|
+
}
|
|
3568
3621
|
export {
|
|
3569
3622
|
DEFAULT_MAX_DOWNLOAD_SIZE,
|
|
3570
3623
|
DelayedPromise,
|
|
@@ -3606,10 +3659,12 @@ export {
|
|
|
3606
3659
|
getRuntimeEnvironmentUserAgent,
|
|
3607
3660
|
injectJsonInstructionIntoMessages,
|
|
3608
3661
|
isAbortError,
|
|
3662
|
+
isArrayBuffer,
|
|
3609
3663
|
isBrowserRuntime,
|
|
3610
3664
|
isNonNullable,
|
|
3611
3665
|
isParsableJson,
|
|
3612
3666
|
isSameOrigin,
|
|
3667
|
+
isUint8Array,
|
|
3613
3668
|
isUrlSupported,
|
|
3614
3669
|
jsonSchema,
|
|
3615
3670
|
lazySchema,
|
|
@@ -3631,6 +3686,7 @@ export {
|
|
|
3631
3686
|
safeParseJSON,
|
|
3632
3687
|
safeValidateTypes,
|
|
3633
3688
|
secureJsonParse,
|
|
3689
|
+
stringifyWithBigIntAndCycles,
|
|
3634
3690
|
stripFileExtension,
|
|
3635
3691
|
tool,
|
|
3636
3692
|
validateDownloadUrl,
|