@ai-sdk/provider-utils 1.0.5 → 1.0.6

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.
@@ -125,7 +125,7 @@ async function convertResponseStreamToArray(response) {
125
125
  );
126
126
  }
127
127
 
128
- // ../../node_modules/.pnpm/outvariant@1.4.2/node_modules/outvariant/lib/index.mjs
128
+ // ../../node_modules/.pnpm/outvariant@1.4.3/node_modules/outvariant/lib/index.mjs
129
129
  var POSITIONALS_EXP = /(%?)(%([sdijo]))/g;
130
130
  function serializePositional(positional, flag) {
131
131
  switch (flag) {
@@ -196,10 +196,12 @@ var invariant = (predicate, message3, ...positionals) => {
196
196
  };
197
197
  invariant.as = (ErrorConstructor, predicate, message3, ...positionals) => {
198
198
  if (!predicate) {
199
- const formatMessage2 = positionals.length === 0 ? message3 : format(message3, positionals);
199
+ const formatMessage2 = positionals.length === 0 ? message3 : format(message3, ...positionals);
200
200
  let error3;
201
201
  try {
202
- error3 = Reflect.construct(ErrorConstructor, [formatMessage2]);
202
+ error3 = Reflect.construct(ErrorConstructor, [
203
+ formatMessage2
204
+ ]);
203
205
  } catch (err) {
204
206
  error3 = ErrorConstructor(formatMessage2);
205
207
  }
@@ -916,7 +918,7 @@ async function serializeResponse(response) {
916
918
  };
917
919
  }
918
920
 
919
- // ../../node_modules/.pnpm/path-to-regexp@6.2.1/node_modules/path-to-regexp/dist.es2015/index.js
921
+ // ../../node_modules/.pnpm/path-to-regexp@6.2.2/node_modules/path-to-regexp/dist.es2015/index.js
920
922
  function lexer(str) {
921
923
  var tokens = [];
922
924
  var i = 0;
@@ -1156,7 +1158,7 @@ function tokensToRegexp(tokens, keys, options) {
1156
1158
  if (options === void 0) {
1157
1159
  options = {};
1158
1160
  }
1159
- var _a3 = options.strict, strict = _a3 === void 0 ? false : _a3, _b2 = options.start, start = _b2 === void 0 ? true : _b2, _c = options.end, end = _c === void 0 ? true : _c, _d = options.encode, encode = _d === void 0 ? function(x) {
1161
+ var _a3 = options.strict, strict = _a3 === void 0 ? false : _a3, _b2 = options.start, start = _b2 === void 0 ? true : _b2, _c2 = options.end, end = _c2 === void 0 ? true : _c2, _d = options.encode, encode = _d === void 0 ? function(x) {
1160
1162
  return x;
1161
1163
  } : _d, _e = options.delimiter, delimiter = _e === void 0 ? "/#?" : _e, _f = options.endsWith, endsWith = _f === void 0 ? "" : _f;
1162
1164
  var endsWithRe = "[".concat(escapeString(endsWith), "]|$");
@@ -1230,6 +1232,88 @@ function isNodeProcess() {
1230
1232
  return false;
1231
1233
  }
1232
1234
 
1235
+ // ../../node_modules/.pnpm/outvariant@1.4.2/node_modules/outvariant/lib/index.mjs
1236
+ var POSITIONALS_EXP2 = /(%?)(%([sdijo]))/g;
1237
+ function serializePositional2(positional, flag) {
1238
+ switch (flag) {
1239
+ case "s":
1240
+ return positional;
1241
+ case "d":
1242
+ case "i":
1243
+ return Number(positional);
1244
+ case "j":
1245
+ return JSON.stringify(positional);
1246
+ case "o": {
1247
+ if (typeof positional === "string") {
1248
+ return positional;
1249
+ }
1250
+ const json = JSON.stringify(positional);
1251
+ if (json === "{}" || json === "[]" || /^\[object .+?\]$/.test(json)) {
1252
+ return positional;
1253
+ }
1254
+ return json;
1255
+ }
1256
+ }
1257
+ }
1258
+ function format2(message3, ...positionals) {
1259
+ if (positionals.length === 0) {
1260
+ return message3;
1261
+ }
1262
+ let positionalIndex = 0;
1263
+ let formattedMessage = message3.replace(
1264
+ POSITIONALS_EXP2,
1265
+ (match2, isEscaped, _, flag) => {
1266
+ const positional = positionals[positionalIndex];
1267
+ const value = serializePositional2(positional, flag);
1268
+ if (!isEscaped) {
1269
+ positionalIndex++;
1270
+ return value;
1271
+ }
1272
+ return match2;
1273
+ }
1274
+ );
1275
+ if (positionalIndex < positionals.length) {
1276
+ formattedMessage += ` ${positionals.slice(positionalIndex).join(" ")}`;
1277
+ }
1278
+ formattedMessage = formattedMessage.replace(/%{2,2}/g, "%");
1279
+ return formattedMessage;
1280
+ }
1281
+ var STACK_FRAMES_TO_IGNORE2 = 2;
1282
+ function cleanErrorStack2(error3) {
1283
+ if (!error3.stack) {
1284
+ return;
1285
+ }
1286
+ const nextStack = error3.stack.split("\n");
1287
+ nextStack.splice(1, STACK_FRAMES_TO_IGNORE2);
1288
+ error3.stack = nextStack.join("\n");
1289
+ }
1290
+ var InvariantError2 = class extends Error {
1291
+ constructor(message3, ...positionals) {
1292
+ super(message3);
1293
+ this.message = message3;
1294
+ this.name = "Invariant Violation";
1295
+ this.message = format2(message3, ...positionals);
1296
+ cleanErrorStack2(this);
1297
+ }
1298
+ };
1299
+ var invariant2 = (predicate, message3, ...positionals) => {
1300
+ if (!predicate) {
1301
+ throw new InvariantError2(message3, ...positionals);
1302
+ }
1303
+ };
1304
+ invariant2.as = (ErrorConstructor, predicate, message3, ...positionals) => {
1305
+ if (!predicate) {
1306
+ const formatMessage2 = positionals.length === 0 ? message3 : format2(message3, positionals);
1307
+ let error3;
1308
+ try {
1309
+ error3 = Reflect.construct(ErrorConstructor, [formatMessage2]);
1310
+ } catch (err) {
1311
+ error3 = ErrorConstructor(formatMessage2);
1312
+ }
1313
+ throw error3;
1314
+ }
1315
+ };
1316
+
1233
1317
  // ../../node_modules/.pnpm/@open-draft+logger@0.3.0/node_modules/@open-draft/logger/lib/index.mjs
1234
1318
  var __defProp3 = Object.defineProperty;
1235
1319
  var __export2 = (target, all) => {
@@ -1458,21 +1542,21 @@ var PerformanceEntry = class {
1458
1542
  var noop = () => void 0;
1459
1543
  function log(message3, ...positionals) {
1460
1544
  if (IS_NODE) {
1461
- process.stdout.write(format(message3, ...positionals) + "\n");
1545
+ process.stdout.write(format2(message3, ...positionals) + "\n");
1462
1546
  return;
1463
1547
  }
1464
1548
  console.log(message3, ...positionals);
1465
1549
  }
1466
1550
  function warn2(message3, ...positionals) {
1467
1551
  if (IS_NODE) {
1468
- process.stderr.write(format(message3, ...positionals) + "\n");
1552
+ process.stderr.write(format2(message3, ...positionals) + "\n");
1469
1553
  return;
1470
1554
  }
1471
1555
  console.warn(message3, ...positionals);
1472
1556
  }
1473
1557
  function error2(message3, ...positionals) {
1474
1558
  if (IS_NODE) {
1475
- process.stderr.write(format(message3, ...positionals) + "\n");
1559
+ process.stderr.write(format2(message3, ...positionals) + "\n");
1476
1560
  return;
1477
1561
  }
1478
1562
  console.error(message3, ...positionals);
@@ -2009,7 +2093,7 @@ var require_cookie = __commonJS2({
2009
2093
  var import_cookie = __toESM3(require_cookie(), 1);
2010
2094
  var source_default2 = import_cookie.default;
2011
2095
 
2012
- // ../../node_modules/.pnpm/@mswjs+cookies@1.1.0/node_modules/@mswjs/cookies/lib/index.mjs
2096
+ // ../../node_modules/.pnpm/@mswjs+cookies@1.1.1/node_modules/@mswjs/cookies/lib/index.mjs
2013
2097
  var __create4 = Object.create;
2014
2098
  var __defProp5 = Object.defineProperty;
2015
2099
  var __getOwnPropDesc4 = Object.getOwnPropertyDescriptor;
@@ -2213,6 +2297,7 @@ function supportsLocalStorage() {
2213
2297
  return false;
2214
2298
  }
2215
2299
  }
2300
+ var hasLocalStorageSupport = supportsLocalStorage();
2216
2301
  function isPropertyAccessible2(object, method) {
2217
2302
  try {
2218
2303
  object[method];
@@ -2284,7 +2369,7 @@ var CookieStore = class {
2284
2369
  this.store.clear();
2285
2370
  }
2286
2371
  hydrate() {
2287
- if (!supportsLocalStorage()) {
2372
+ if (!hasLocalStorageSupport) {
2288
2373
  return;
2289
2374
  }
2290
2375
  const persistedCookies = localStorage.getItem(PERSISTENCY_KEY);
@@ -2319,7 +2404,7 @@ Invalid value has been removed from localStorage to prevent subsequent failed pa
2319
2404
  }
2320
2405
  }
2321
2406
  persist() {
2322
- if (!supportsLocalStorage()) {
2407
+ if (!hasLocalStorageSupport) {
2323
2408
  return;
2324
2409
  }
2325
2410
  const serializedCookies = Array.from(this.store.entries()).map(
@@ -2495,7 +2580,7 @@ var http = {
2495
2580
  options: createHttpHandler(HttpMethods.OPTIONS)
2496
2581
  };
2497
2582
 
2498
- // ../../node_modules/.pnpm/headers-polyfill@4.0.2/node_modules/headers-polyfill/lib/index.mjs
2583
+ // ../../node_modules/.pnpm/headers-polyfill@4.0.3/node_modules/headers-polyfill/lib/index.mjs
2499
2584
  var __create5 = Object.create;
2500
2585
  var __defProp6 = Object.defineProperty;
2501
2586
  var __getOwnPropDesc5 = Object.getOwnPropertyDescriptor;
@@ -2771,10 +2856,12 @@ var RAW_HEADER_NAMES = Symbol("rawHeaderNames");
2771
2856
  var HEADER_VALUE_DELIMITER = ", ";
2772
2857
  var _a;
2773
2858
  var _b;
2859
+ var _c;
2774
2860
  var Headers2 = class _Headers {
2775
2861
  constructor(init) {
2776
2862
  this[_a] = {};
2777
2863
  this[_b] = /* @__PURE__ */ new Map();
2864
+ this[_c] = "Headers";
2778
2865
  if (["Headers", "HeadersPolyfill"].includes(init == null ? void 0 : init.constructor.name) || init instanceof _Headers || typeof globalThis.Headers !== "undefined" && init instanceof globalThis.Headers) {
2779
2866
  const initialHeaders = init;
2780
2867
  initialHeaders.forEach((value, name) => {
@@ -2797,7 +2884,7 @@ var Headers2 = class _Headers {
2797
2884
  });
2798
2885
  }
2799
2886
  }
2800
- [(_a = NORMALIZED_HEADERS, _b = RAW_HEADER_NAMES, Symbol.iterator)]() {
2887
+ [(_a = NORMALIZED_HEADERS, _b = RAW_HEADER_NAMES, _c = Symbol.toStringTag, Symbol.iterator)]() {
2801
2888
  return this.entries();
2802
2889
  }
2803
2890
  *keys() {
@@ -3003,7 +3090,7 @@ function readResponseCookies(request2, response) {
3003
3090
 
3004
3091
  // ../../node_modules/.pnpm/msw@2.3.1_typescript@5.1.3/node_modules/msw/lib/core/utils/handleRequest.mjs
3005
3092
  async function handleRequest(request2, requestId, handlers, options, emitter, handleRequestOptions) {
3006
- var _a3, _b2, _c, _d, _e, _f;
3093
+ var _a3, _b2, _c2, _d, _e, _f;
3007
3094
  emitter.emit("request:start", { request: request2, requestId });
3008
3095
  if (request2.headers.get("x-msw-intention") === "bypass") {
3009
3096
  emitter.emit("request:end", { request: request2, requestId });
@@ -3036,7 +3123,7 @@ async function handleRequest(request2, requestId, handlers, options, emitter, ha
3036
3123
  const { response } = lookupResult.data;
3037
3124
  if (!response) {
3038
3125
  emitter.emit("request:end", { request: request2, requestId });
3039
- (_c = handleRequestOptions == null ? void 0 : handleRequestOptions.onPassthroughResponse) == null ? void 0 : _c.call(handleRequestOptions, request2);
3126
+ (_c2 = handleRequestOptions == null ? void 0 : handleRequestOptions.onPassthroughResponse) == null ? void 0 : _c2.call(handleRequestOptions, request2);
3040
3127
  return;
3041
3128
  }
3042
3129
  if (response.status === 302 && response.headers.get("x-msw-intention") === "passthrough") {
@@ -3260,7 +3347,7 @@ var RequestController = class {
3260
3347
  this.responsePromise = new DeferredPromise();
3261
3348
  }
3262
3349
  respondWith(response) {
3263
- invariant(
3350
+ invariant2(
3264
3351
  this.responsePromise.state === "pending",
3265
3352
  'Failed to respond to "%s %s" request: the "request" event has already been responded to.',
3266
3353
  this.request.method,
@@ -4567,7 +4654,7 @@ var XMLHttpRequestController = class {
4567
4654
  }
4568
4655
  }
4569
4656
  get responseText() {
4570
- invariant(
4657
+ invariant2(
4571
4658
  this.request.responseType === "" || this.request.responseType === "text",
4572
4659
  "InvalidStateError: The object is in invalid state."
4573
4660
  );
@@ -4579,7 +4666,7 @@ var XMLHttpRequestController = class {
4579
4666
  return responseText;
4580
4667
  }
4581
4668
  get responseXML() {
4582
- invariant(
4669
+ invariant2(
4583
4670
  this.request.responseType === "" || this.request.responseType === "document",
4584
4671
  "InvalidStateError: The object is in invalid state."
4585
4672
  );
@@ -4838,7 +4925,7 @@ var _XMLHttpRequestInterceptor = class extends Interceptor {
4838
4925
  const logger7 = this.logger.extend("setup");
4839
4926
  logger7.info('patching "XMLHttpRequest" module...');
4840
4927
  const PureXMLHttpRequest = globalThis.XMLHttpRequest;
4841
- invariant(
4928
+ invariant2(
4842
4929
  !PureXMLHttpRequest[IS_PATCHED_MODULE],
4843
4930
  'Failed to patch the "XMLHttpRequest" module: already patched.'
4844
4931
  );
@@ -4888,7 +4975,7 @@ var _FetchInterceptor = class extends Interceptor {
4888
4975
  }
4889
4976
  async setup() {
4890
4977
  const pureFetch = globalThis.fetch;
4891
- invariant(
4978
+ invariant2(
4892
4979
  !pureFetch[IS_PATCHED_MODULE],
4893
4980
  'Failed to patch the "fetch" module: already patched.'
4894
4981
  );