ai 6.0.221 → 6.0.222

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
@@ -1171,7 +1171,7 @@ import {
1171
1171
  } from "@ai-sdk/provider-utils";
1172
1172
 
1173
1173
  // src/version.ts
1174
- var VERSION = true ? "6.0.221" : "0.0.0-test";
1174
+ var VERSION = true ? "6.0.222" : "0.0.0-test";
1175
1175
 
1176
1176
  // src/util/download/download.ts
1177
1177
  var download = async ({
@@ -11893,13 +11893,14 @@ async function experimental_generateVideo({
11893
11893
  abortSignal
11894
11894
  });
11895
11895
  const { prompt, image } = normalizePrompt2(promptArg);
11896
- const normalizedFrameImages = frameImages == null ? void 0 : frameImages.map((frame) => ({
11897
- image: normalizeImageData(frame.image),
11898
- frameType: frame.frameType
11899
- }));
11900
- const normalizedInputReferences = inputReferences == null ? void 0 : inputReferences.map(
11901
- (reference) => normalizeImageData(reference)
11902
- );
11896
+ const normalizedFrameImages = frameImages == null ? void 0 : frameImages.flatMap((frame) => {
11897
+ const normalizedImage = normalizeImageData(frame.image);
11898
+ return normalizedImage != null ? [{ image: normalizedImage, frameType: frame.frameType }] : [];
11899
+ });
11900
+ const normalizedInputReferences = inputReferences == null ? void 0 : inputReferences.flatMap((reference) => {
11901
+ const normalized = normalizeReferenceData(reference);
11902
+ return normalized != null ? [normalized] : [];
11903
+ });
11903
11904
  const effectiveInputReferences = normalizedFrameImages != null && normalizedFrameImages.length > 0 ? void 0 : normalizedInputReferences;
11904
11905
  const warnings = [];
11905
11906
  if (normalizedFrameImages != null && normalizedFrameImages.length > 0 && normalizedInputReferences != null && normalizedInputReferences.length > 0) {
@@ -12053,8 +12054,12 @@ function normalizePrompt2(promptArg) {
12053
12054
  image: promptArg.image != null ? normalizeImageData(promptArg.image) : void 0
12054
12055
  };
12055
12056
  }
12056
- function normalizeImageData(dataContent) {
12057
- var _a22, _b;
12057
+ function detectFileMediaType(data, restrictToImages) {
12058
+ var _a22;
12059
+ const detected = restrictToImages ? detectMediaType({ data, signatures: imageMediaTypeSignatures }) : (_a22 = detectMediaType({ data, signatures: imageMediaTypeSignatures })) != null ? _a22 : detectMediaType({ data, signatures: videoMediaTypeSignatures });
12060
+ return detected != null ? detected : "image/png";
12061
+ }
12062
+ function normalizeImageData(dataContent, { restrictToImages = true } = {}) {
12058
12063
  if (typeof dataContent === "string") {
12059
12064
  if (dataContent.startsWith("http://") || dataContent.startsWith("https://")) {
12060
12065
  return {
@@ -12064,27 +12069,46 @@ function normalizeImageData(dataContent) {
12064
12069
  }
12065
12070
  if (dataContent.startsWith("data:")) {
12066
12071
  const { mediaType, base64Content } = splitDataUrl(dataContent);
12072
+ const data = convertBase64ToUint8Array6(base64Content != null ? base64Content : "");
12067
12073
  return {
12068
12074
  type: "file",
12069
- mediaType: mediaType != null ? mediaType : "image/png",
12070
- data: convertBase64ToUint8Array6(base64Content != null ? base64Content : "")
12075
+ mediaType: mediaType != null ? mediaType : detectFileMediaType(data, restrictToImages),
12076
+ data
12071
12077
  };
12072
12078
  }
12073
- const bytes2 = convertBase64ToUint8Array6(dataContent);
12079
+ const bytes = convertBase64ToUint8Array6(dataContent);
12074
12080
  return {
12075
12081
  type: "file",
12076
- mediaType: (_a22 = detectMediaType({
12077
- data: bytes2,
12078
- signatures: imageMediaTypeSignatures
12079
- })) != null ? _a22 : "image/png",
12080
- data: bytes2
12082
+ mediaType: detectFileMediaType(bytes, restrictToImages),
12083
+ data: bytes
12081
12084
  };
12082
12085
  }
12083
- const bytes = convertDataContentToUint8Array(dataContent);
12086
+ if (dataContent instanceof Uint8Array || dataContent instanceof ArrayBuffer) {
12087
+ const bytes = dataContent instanceof Uint8Array ? dataContent : new Uint8Array(dataContent);
12088
+ return {
12089
+ type: "file",
12090
+ mediaType: detectFileMediaType(bytes, restrictToImages),
12091
+ data: bytes
12092
+ };
12093
+ }
12094
+ return void 0;
12095
+ }
12096
+ function normalizeReferenceData(reference) {
12097
+ const isObjectForm = typeof reference === "object" && reference != null && !(reference instanceof Uint8Array) && !(reference instanceof ArrayBuffer) && "data" in reference;
12098
+ if (!isObjectForm) {
12099
+ return normalizeImageData(reference, {
12100
+ restrictToImages: false
12101
+ });
12102
+ }
12103
+ const normalized = normalizeImageData(reference.data, {
12104
+ restrictToImages: false
12105
+ });
12106
+ if (normalized == null) {
12107
+ return normalized;
12108
+ }
12084
12109
  return {
12085
- type: "file",
12086
- mediaType: (_b = detectMediaType({ data: bytes, signatures: imageMediaTypeSignatures })) != null ? _b : "image/png",
12087
- data: bytes
12110
+ ...normalized,
12111
+ ...reference.mediaType != null ? { mediaType: reference.mediaType } : {}
12088
12112
  };
12089
12113
  }
12090
12114
  async function invokeModelMaxVideosPerCall(model) {