ai 4.3.7 → 4.3.9
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 +12 -0
- package/dist/index.js +53 -38
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +18 -3
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/rsc/dist/rsc-server.mjs +18 -3
- package/rsc/dist/rsc-server.mjs.map +1 -1
package/dist/index.mjs
CHANGED
@@ -862,6 +862,7 @@ var DefaultGeneratedFileWithType = class extends DefaultGeneratedFile {
|
|
862
862
|
};
|
863
863
|
|
864
864
|
// core/util/detect-mimetype.ts
|
865
|
+
import { convertBase64ToUint8Array as convertBase64ToUint8Array2 } from "@ai-sdk/provider-utils";
|
865
866
|
var imageMimeTypeSignatures = [
|
866
867
|
{
|
867
868
|
mimeType: "image/gif",
|
@@ -967,12 +968,26 @@ var audioMimeTypeSignatures = [
|
|
967
968
|
base64Prefix: "ZnR5cA"
|
968
969
|
}
|
969
970
|
];
|
971
|
+
var stripID3 = (data) => {
|
972
|
+
const bytes = typeof data === "string" ? convertBase64ToUint8Array2(data) : data;
|
973
|
+
const id3Size = (bytes[6] & 127) << 21 | (bytes[7] & 127) << 14 | (bytes[8] & 127) << 7 | bytes[9] & 127;
|
974
|
+
return bytes.slice(id3Size + 10);
|
975
|
+
};
|
976
|
+
function stripID3TagsIfPresent(data) {
|
977
|
+
const hasId3 = typeof data === "string" && data.startsWith("SUQz") || typeof data !== "string" && data.length > 10 && data[0] === 73 && // 'I'
|
978
|
+
data[1] === 68 && // 'D'
|
979
|
+
data[2] === 51;
|
980
|
+
return hasId3 ? stripID3(data) : data;
|
981
|
+
}
|
970
982
|
function detectMimeType({
|
971
983
|
data,
|
972
984
|
signatures
|
973
985
|
}) {
|
986
|
+
const processedData = stripID3TagsIfPresent(data);
|
974
987
|
for (const signature of signatures) {
|
975
|
-
if (typeof
|
988
|
+
if (typeof processedData === "string" ? processedData.startsWith(signature.base64Prefix) : processedData.length >= signature.bytesPrefix.length && signature.bytesPrefix.every(
|
989
|
+
(byte, index) => processedData[index] === byte
|
990
|
+
)) {
|
976
991
|
return signature.mimeType;
|
977
992
|
}
|
978
993
|
}
|
@@ -1144,7 +1159,7 @@ async function download({ url }) {
|
|
1144
1159
|
|
1145
1160
|
// core/prompt/data-content.ts
|
1146
1161
|
import {
|
1147
|
-
convertBase64ToUint8Array as
|
1162
|
+
convertBase64ToUint8Array as convertBase64ToUint8Array3,
|
1148
1163
|
convertUint8ArrayToBase64 as convertUint8ArrayToBase642
|
1149
1164
|
} from "@ai-sdk/provider-utils";
|
1150
1165
|
|
@@ -1200,7 +1215,7 @@ function convertDataContentToUint8Array(content) {
|
|
1200
1215
|
}
|
1201
1216
|
if (typeof content === "string") {
|
1202
1217
|
try {
|
1203
|
-
return
|
1218
|
+
return convertBase64ToUint8Array3(content);
|
1204
1219
|
} catch (error) {
|
1205
1220
|
throw new InvalidDataContentError({
|
1206
1221
|
message: "Invalid data content. Content string is not a base64-encoded media.",
|