@ai-sdk/provider-utils 4.0.63 → 4.0.64

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/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
- return Uint8Array.from(latin1string, (byte) => byte.codePointAt(0));
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 instanceof Uint8Array ? convertUint8ArrayToBase64(value) : value;
213
+ return isUint8Array(value) ? convertUint8ArrayToBase64(value) : value;
188
214
  }
189
215
 
190
216
  // src/convert-image-model-file-to-data-uri.ts
@@ -907,7 +933,7 @@ function withUserAgentSuffix(headers, ...userAgentSuffixParts) {
907
933
  }
908
934
 
909
935
  // src/version.ts
910
- var VERSION = true ? "4.0.63" : "0.0.0-test";
936
+ var VERSION = true ? "4.0.64" : "0.0.0-test";
911
937
 
912
938
  // src/get-from-api.ts
913
939
  var getOriginalFetch = () => globalThis.fetch;
@@ -3565,6 +3591,27 @@ async function* executeTool({
3565
3591
  import {
3566
3592
  EventSourceParserStream as EventSourceParserStream2
3567
3593
  } from "eventsource-parser/stream";
3594
+
3595
+ // src/stringify-with-bigint-and-cycles.ts
3596
+ function stringifyWithBigIntAndCycles(value) {
3597
+ const ancestors = [];
3598
+ return JSON.stringify(value, function(_key, value2) {
3599
+ if (typeof value2 === "bigint") {
3600
+ return value2.toString();
3601
+ }
3602
+ if (typeof value2 !== "object" || value2 === null) {
3603
+ return value2;
3604
+ }
3605
+ while (ancestors.length > 0 && ancestors.at(-1) !== this) {
3606
+ ancestors.pop();
3607
+ }
3608
+ if (ancestors.includes(value2)) {
3609
+ return "[Circular]";
3610
+ }
3611
+ ancestors.push(value2);
3612
+ return value2;
3613
+ });
3614
+ }
3568
3615
  export {
3569
3616
  DEFAULT_MAX_DOWNLOAD_SIZE,
3570
3617
  DelayedPromise,
@@ -3606,10 +3653,12 @@ export {
3606
3653
  getRuntimeEnvironmentUserAgent,
3607
3654
  injectJsonInstructionIntoMessages,
3608
3655
  isAbortError,
3656
+ isArrayBuffer,
3609
3657
  isBrowserRuntime,
3610
3658
  isNonNullable,
3611
3659
  isParsableJson,
3612
3660
  isSameOrigin,
3661
+ isUint8Array,
3613
3662
  isUrlSupported,
3614
3663
  jsonSchema,
3615
3664
  lazySchema,
@@ -3631,6 +3680,7 @@ export {
3631
3680
  safeParseJSON,
3632
3681
  safeValidateTypes,
3633
3682
  secureJsonParse,
3683
+ stringifyWithBigIntAndCycles,
3634
3684
  stripFileExtension,
3635
3685
  tool,
3636
3686
  validateDownloadUrl,