@ai-sdk/provider-utils 3.0.16 → 3.0.18

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
@@ -77,6 +77,53 @@ function createAbortError() {
77
77
  return new DOMException("Delay was aborted", "AbortError");
78
78
  }
79
79
 
80
+ // src/delayed-promise.ts
81
+ var DelayedPromise = class {
82
+ constructor() {
83
+ this.status = { type: "pending" };
84
+ this._resolve = void 0;
85
+ this._reject = void 0;
86
+ }
87
+ get promise() {
88
+ if (this._promise) {
89
+ return this._promise;
90
+ }
91
+ this._promise = new Promise((resolve2, reject) => {
92
+ if (this.status.type === "resolved") {
93
+ resolve2(this.status.value);
94
+ } else if (this.status.type === "rejected") {
95
+ reject(this.status.error);
96
+ }
97
+ this._resolve = resolve2;
98
+ this._reject = reject;
99
+ });
100
+ return this._promise;
101
+ }
102
+ resolve(value) {
103
+ var _a;
104
+ this.status = { type: "resolved", value };
105
+ if (this._promise) {
106
+ (_a = this._resolve) == null ? void 0 : _a.call(this, value);
107
+ }
108
+ }
109
+ reject(error) {
110
+ var _a;
111
+ this.status = { type: "rejected", error };
112
+ if (this._promise) {
113
+ (_a = this._reject) == null ? void 0 : _a.call(this, error);
114
+ }
115
+ }
116
+ isResolved() {
117
+ return this.status.type === "resolved";
118
+ }
119
+ isRejected() {
120
+ return this.status.type === "rejected";
121
+ }
122
+ isPending() {
123
+ return this.status.type === "pending";
124
+ }
125
+ };
126
+
80
127
  // src/extract-response-headers.ts
81
128
  function extractResponseHeaders(response) {
82
129
  return Object.fromEntries([...response.headers]);
@@ -216,7 +263,7 @@ function withUserAgentSuffix(headers, ...userAgentSuffixParts) {
216
263
  }
217
264
 
218
265
  // src/version.ts
219
- var VERSION = true ? "3.0.16" : "0.0.0-test";
266
+ var VERSION = true ? "3.0.18" : "0.0.0-test";
220
267
 
221
268
  // src/get-from-api.ts
222
269
  var getOriginalFetch = () => globalThis.fetch;
@@ -485,7 +532,11 @@ function filter(obj) {
485
532
  }
486
533
  function secureJsonParse(text) {
487
534
  const { stackTraceLimit } = Error;
488
- Error.stackTraceLimit = 0;
535
+ try {
536
+ Error.stackTraceLimit = 0;
537
+ } catch (e) {
538
+ return _parse(text);
539
+ }
489
540
  try {
490
541
  return _parse(text);
491
542
  } finally {
@@ -2341,6 +2392,7 @@ import {
2341
2392
  EventSourceParserStream as EventSourceParserStream2
2342
2393
  } from "eventsource-parser/stream";
2343
2394
  export {
2395
+ DelayedPromise,
2344
2396
  EventSourceParserStream2 as EventSourceParserStream,
2345
2397
  VERSION,
2346
2398
  asSchema,