ai 3.1.5 → 3.1.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.
@@ -204,7 +204,15 @@ function convertDataContentToUint8Array(content) {
204
204
  return content;
205
205
  }
206
206
  if (typeof content === "string") {
207
- return convertBase64ToUint8Array(content);
207
+ try {
208
+ return convertBase64ToUint8Array(content);
209
+ } catch (error) {
210
+ throw new InvalidDataContentError({
211
+ message: "Invalid data content. Content string is not a base64-encoded image.",
212
+ content,
213
+ cause: error
214
+ });
215
+ }
208
216
  }
209
217
  if (content instanceof ArrayBuffer) {
210
218
  return new Uint8Array(content);
@@ -1170,7 +1178,7 @@ function createStreamableUI(initialValue) {
1170
1178
  }
1171
1179
  }
1172
1180
  warnUnclosedStream();
1173
- return {
1181
+ const streamable2 = {
1174
1182
  /**
1175
1183
  * The value of the streamable UI. This can be returned from a Server Action and received by the client.
1176
1184
  */
@@ -1182,7 +1190,7 @@ function createStreamableUI(initialValue) {
1182
1190
  assertStream(".update()");
1183
1191
  if (value === currentValue) {
1184
1192
  warnUnclosedStream();
1185
- return;
1193
+ return streamable2;
1186
1194
  }
1187
1195
  const resolvable = createResolvablePromise();
1188
1196
  currentValue = value;
@@ -1190,6 +1198,7 @@ function createStreamableUI(initialValue) {
1190
1198
  resolve = resolvable.resolve;
1191
1199
  reject = resolvable.reject;
1192
1200
  warnUnclosedStream();
1201
+ return streamable2;
1193
1202
  },
1194
1203
  /**
1195
1204
  * This method is used to append a new UI node to the end of the old one.
@@ -1215,6 +1224,7 @@ function createStreamableUI(initialValue) {
1215
1224
  resolve = resolvable.resolve;
1216
1225
  reject = resolvable.reject;
1217
1226
  warnUnclosedStream();
1227
+ return streamable2;
1218
1228
  },
1219
1229
  /**
1220
1230
  * This method is used to signal that there is an error in the UI stream.
@@ -1227,6 +1237,7 @@ function createStreamableUI(initialValue) {
1227
1237
  }
1228
1238
  closed = true;
1229
1239
  reject(error);
1240
+ return streamable2;
1230
1241
  },
1231
1242
  /**
1232
1243
  * This method marks the UI node as finalized. You can either call it without any parameters or with a new UI node as the final state.
@@ -1242,11 +1253,13 @@ function createStreamableUI(initialValue) {
1242
1253
  closed = true;
1243
1254
  if (args.length) {
1244
1255
  resolve({ value: args[0], done: true });
1245
- return;
1256
+ return streamable2;
1246
1257
  }
1247
1258
  resolve({ value: currentValue, done: true });
1259
+ return streamable2;
1248
1260
  }
1249
1261
  };
1262
+ return streamable2;
1250
1263
  }
1251
1264
  var STREAMABLE_VALUE_INTERNAL_LOCK = Symbol("streamable.value.lock");
1252
1265
  function createStreamableValue(initialValue) {
@@ -1343,7 +1356,7 @@ function createStreamableValueImpl(initialValue) {
1343
1356
  }
1344
1357
  currentValue = value;
1345
1358
  }
1346
- return {
1359
+ const streamable2 = {
1347
1360
  /**
1348
1361
  * @internal This is an internal lock to prevent the value from being
1349
1362
  * updated by the user.
@@ -1370,6 +1383,7 @@ function createStreamableValueImpl(initialValue) {
1370
1383
  currentPromise = resolvable.promise;
1371
1384
  resolvePrevious(createWrapped());
1372
1385
  warnUnclosedStream();
1386
+ return streamable2;
1373
1387
  },
1374
1388
  /**
1375
1389
  * This method is used to append a delta string to the current value. It
@@ -1407,6 +1421,7 @@ function createStreamableValueImpl(initialValue) {
1407
1421
  currentPromise = resolvable.promise;
1408
1422
  resolvePrevious(createWrapped());
1409
1423
  warnUnclosedStream();
1424
+ return streamable2;
1410
1425
  },
1411
1426
  /**
1412
1427
  * This method is used to signal that there is an error in the value stream.
@@ -1422,6 +1437,7 @@ function createStreamableValueImpl(initialValue) {
1422
1437
  currentError = error;
1423
1438
  currentPromise = void 0;
1424
1439
  resolvable.resolve({ error });
1440
+ return streamable2;
1425
1441
  },
1426
1442
  /**
1427
1443
  * This method marks the value as finalized. You can either call it without
@@ -1441,11 +1457,13 @@ function createStreamableValueImpl(initialValue) {
1441
1457
  if (args.length) {
1442
1458
  updateValueStates(args[0]);
1443
1459
  resolvable.resolve(createWrapped());
1444
- return;
1460
+ return streamable2;
1445
1461
  }
1446
1462
  resolvable.resolve({});
1463
+ return streamable2;
1447
1464
  }
1448
1465
  };
1466
+ return streamable2;
1449
1467
  }
1450
1468
  function render(options) {
1451
1469
  const ui = createStreamableUI(options.initial);