@ai-sdk/provider-utils 3.0.42 → 3.0.44

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
@@ -740,7 +740,7 @@ function withUserAgentSuffix(headers, ...userAgentSuffixParts) {
740
740
  }
741
741
 
742
742
  // src/version.ts
743
- var VERSION = true ? "3.0.42" : "0.0.0-test";
743
+ var VERSION = true ? "3.0.44" : "0.0.0-test";
744
744
 
745
745
  // src/get-from-api.ts
746
746
  var getOriginalFetch = () => globalThis.fetch;
@@ -3288,9 +3288,21 @@ var { btoa, atob } = globalThis;
3288
3288
  function convertBase64ToUint8Array(base64String) {
3289
3289
  const base64Url = base64String.replace(/-/g, "+").replace(/_/g, "/");
3290
3290
  const latin1string = atob(base64Url);
3291
- return Uint8Array.from(latin1string, (byte) => byte.codePointAt(0));
3291
+ const bytes = new Uint8Array(latin1string.length);
3292
+ for (let i = 0; i < latin1string.length; i++) {
3293
+ bytes[i] = latin1string.charCodeAt(i);
3294
+ }
3295
+ return bytes;
3292
3296
  }
3293
3297
  function convertUint8ArrayToBase64(array) {
3298
+ var _a2;
3299
+ if (typeof ((_a2 = globalThis.Buffer) == null ? void 0 : _a2.from) === "function") {
3300
+ return globalThis.Buffer.from(
3301
+ array.buffer,
3302
+ array.byteOffset,
3303
+ array.byteLength
3304
+ ).toString("base64");
3305
+ }
3294
3306
  const chunks = [];
3295
3307
  const chunkSize = 4096;
3296
3308
  for (let i = 0; i < array.length; i += chunkSize) {
@@ -3298,8 +3310,30 @@ function convertUint8ArrayToBase64(array) {
3298
3310
  }
3299
3311
  return btoa(chunks.join(""));
3300
3312
  }
3313
+ var typedArrayTag = Object.getOwnPropertyDescriptor(
3314
+ Object.getPrototypeOf(Uint8Array.prototype),
3315
+ Symbol.toStringTag
3316
+ ).get;
3317
+ var arrayBufferByteLength = Object.getOwnPropertyDescriptor(
3318
+ ArrayBuffer.prototype,
3319
+ "byteLength"
3320
+ ).get;
3321
+ function isUint8Array(value) {
3322
+ return ArrayBuffer.isView(value) && typedArrayTag.call(value) === "Uint8Array";
3323
+ }
3324
+ function isArrayBuffer(value) {
3325
+ if (typeof value !== "object" || value === null || !("byteLength" in value)) {
3326
+ return false;
3327
+ }
3328
+ try {
3329
+ arrayBufferByteLength.call(value);
3330
+ return true;
3331
+ } catch (e) {
3332
+ return false;
3333
+ }
3334
+ }
3301
3335
  function convertToBase64(value) {
3302
- return value instanceof Uint8Array ? convertUint8ArrayToBase64(value) : value;
3336
+ return isUint8Array(value) ? convertUint8ArrayToBase64(value) : value;
3303
3337
  }
3304
3338
 
3305
3339
  // src/without-trailing-slash.ts
@@ -3336,6 +3370,27 @@ export * from "@standard-schema/spec";
3336
3370
  import {
3337
3371
  EventSourceParserStream as EventSourceParserStream2
3338
3372
  } from "eventsource-parser/stream";
3373
+
3374
+ // src/stringify-with-bigint-and-cycles.ts
3375
+ function stringifyWithBigIntAndCycles(value) {
3376
+ const ancestors = [];
3377
+ return JSON.stringify(value, function(_key, value2) {
3378
+ if (typeof value2 === "bigint") {
3379
+ return value2.toString();
3380
+ }
3381
+ if (typeof value2 !== "object" || value2 === null) {
3382
+ return value2;
3383
+ }
3384
+ while (ancestors.length > 0 && ancestors.at(-1) !== this) {
3385
+ ancestors.pop();
3386
+ }
3387
+ if (ancestors.includes(value2)) {
3388
+ return "[Circular]";
3389
+ }
3390
+ ancestors.push(value2);
3391
+ return value2;
3392
+ });
3393
+ }
3339
3394
  export {
3340
3395
  DEFAULT_MAX_DOWNLOAD_SIZE,
3341
3396
  DelayedPromise,
@@ -3374,9 +3429,11 @@ export {
3374
3429
  getRuntimeEnvironmentUserAgent,
3375
3430
  injectJsonInstructionIntoMessages,
3376
3431
  isAbortError,
3432
+ isArrayBuffer,
3377
3433
  isBrowserRuntime,
3378
3434
  isParsableJson,
3379
3435
  isSameOrigin,
3436
+ isUint8Array,
3380
3437
  isUrlSupported,
3381
3438
  isValidator,
3382
3439
  jsonSchema,
@@ -3398,7 +3455,9 @@ export {
3398
3455
  resolve,
3399
3456
  safeParseJSON,
3400
3457
  safeValidateTypes,
3458
+ secureJsonParse,
3401
3459
  standardSchemaValidator,
3460
+ stringifyWithBigIntAndCycles,
3402
3461
  tool,
3403
3462
  validateDownloadUrl,
3404
3463
  validateTypes,