@ai-sdk/provider-utils 4.0.62 → 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/CHANGELOG.md +14 -0
- package/dist/index.d.mts +10 -1
- package/dist/index.d.ts +10 -1
- package/dist/index.js +64 -3
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +61 -3
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/index.ts +2 -0
- package/src/stringify-with-bigint-and-cycles.ts +26 -0
- package/src/uint8-utils.ts +47 -2
package/dist/index.mjs
CHANGED
|
@@ -165,9 +165,21 @@ 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) {
|
|
175
|
+
var _a2;
|
|
176
|
+
if (typeof ((_a2 = globalThis.Buffer) == null ? void 0 : _a2.from) === "function") {
|
|
177
|
+
return globalThis.Buffer.from(
|
|
178
|
+
array.buffer,
|
|
179
|
+
array.byteOffset,
|
|
180
|
+
array.byteLength
|
|
181
|
+
).toString("base64");
|
|
182
|
+
}
|
|
171
183
|
const chunks = [];
|
|
172
184
|
const chunkSize = 4096;
|
|
173
185
|
for (let i = 0; i < array.length; i += chunkSize) {
|
|
@@ -175,8 +187,30 @@ function convertUint8ArrayToBase64(array) {
|
|
|
175
187
|
}
|
|
176
188
|
return btoa(chunks.join(""));
|
|
177
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
|
+
}
|
|
178
212
|
function convertToBase64(value) {
|
|
179
|
-
return value
|
|
213
|
+
return isUint8Array(value) ? convertUint8ArrayToBase64(value) : value;
|
|
180
214
|
}
|
|
181
215
|
|
|
182
216
|
// src/convert-image-model-file-to-data-uri.ts
|
|
@@ -899,7 +933,7 @@ function withUserAgentSuffix(headers, ...userAgentSuffixParts) {
|
|
|
899
933
|
}
|
|
900
934
|
|
|
901
935
|
// src/version.ts
|
|
902
|
-
var VERSION = true ? "4.0.
|
|
936
|
+
var VERSION = true ? "4.0.64" : "0.0.0-test";
|
|
903
937
|
|
|
904
938
|
// src/get-from-api.ts
|
|
905
939
|
var getOriginalFetch = () => globalThis.fetch;
|
|
@@ -3557,6 +3591,27 @@ async function* executeTool({
|
|
|
3557
3591
|
import {
|
|
3558
3592
|
EventSourceParserStream as EventSourceParserStream2
|
|
3559
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
|
+
}
|
|
3560
3615
|
export {
|
|
3561
3616
|
DEFAULT_MAX_DOWNLOAD_SIZE,
|
|
3562
3617
|
DelayedPromise,
|
|
@@ -3598,10 +3653,12 @@ export {
|
|
|
3598
3653
|
getRuntimeEnvironmentUserAgent,
|
|
3599
3654
|
injectJsonInstructionIntoMessages,
|
|
3600
3655
|
isAbortError,
|
|
3656
|
+
isArrayBuffer,
|
|
3601
3657
|
isBrowserRuntime,
|
|
3602
3658
|
isNonNullable,
|
|
3603
3659
|
isParsableJson,
|
|
3604
3660
|
isSameOrigin,
|
|
3661
|
+
isUint8Array,
|
|
3605
3662
|
isUrlSupported,
|
|
3606
3663
|
jsonSchema,
|
|
3607
3664
|
lazySchema,
|
|
@@ -3623,6 +3680,7 @@ export {
|
|
|
3623
3680
|
safeParseJSON,
|
|
3624
3681
|
safeValidateTypes,
|
|
3625
3682
|
secureJsonParse,
|
|
3683
|
+
stringifyWithBigIntAndCycles,
|
|
3626
3684
|
stripFileExtension,
|
|
3627
3685
|
tool,
|
|
3628
3686
|
validateDownloadUrl,
|