ai 5.0.251 → 5.0.253

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 CHANGED
@@ -1,5 +1,24 @@
1
1
  # ai
2
2
 
3
+ ## 5.0.253
4
+
5
+ ### Patch Changes
6
+
7
+ - 5643ec9: fix(ai): allow manual continuations to reuse JSON tool outputs with undefined object properties
8
+ - Updated dependencies [b436246]
9
+ - @ai-sdk/gateway@2.0.147
10
+
11
+ ## 5.0.252
12
+
13
+ ### Patch Changes
14
+
15
+ - 2c12cd3: fix(ai): skip `smoothStream` delays while the document is hidden
16
+ - Updated dependencies [cfa33a0]
17
+ - Updated dependencies [8ee6f7d]
18
+ - Updated dependencies [2287da5]
19
+ - Updated dependencies [526f371]
20
+ - @ai-sdk/gateway@2.0.146
21
+
3
22
  ## 5.0.251
4
23
 
5
24
  ### Patch Changes
package/dist/index.d.mts CHANGED
@@ -1214,7 +1214,7 @@ type ChunkDetector = (buffer: string) => string | undefined | null;
1214
1214
  /**
1215
1215
  * Smooths text streaming output.
1216
1216
  *
1217
- * @param delayInMs - The delay in milliseconds between each chunk. Defaults to 10ms. Can be set to `null` to skip the delay.
1217
+ * @param delayInMs - The delay in milliseconds between each chunk. Defaults to 10ms. Can be set to `null` to skip the delay. The delay is skipped while the document is hidden (e.g. browser background tabs), where timer throttling would otherwise stall the stream.
1218
1218
  * @param chunking - Controls how the text is chunked for streaming. Use "word" to stream word by word (default), "line" to stream line by line, or provide a custom RegExp pattern for custom chunking.
1219
1219
  *
1220
1220
  * @returns A transform stream that smooths text streaming output.
package/dist/index.d.ts CHANGED
@@ -1214,7 +1214,7 @@ type ChunkDetector = (buffer: string) => string | undefined | null;
1214
1214
  /**
1215
1215
  * Smooths text streaming output.
1216
1216
  *
1217
- * @param delayInMs - The delay in milliseconds between each chunk. Defaults to 10ms. Can be set to `null` to skip the delay.
1217
+ * @param delayInMs - The delay in milliseconds between each chunk. Defaults to 10ms. Can be set to `null` to skip the delay. The delay is skipped while the document is hidden (e.g. browser background tabs), where timer throttling would otherwise stall the stream.
1218
1218
  * @param chunking - Controls how the text is chunked for streaming. Use "word" to stream word by word (default), "line" to stream line by line, or provide a custom RegExp pattern for custom chunking.
1219
1219
  *
1220
1220
  * @returns A transform stream that smooths text streaming output.
package/dist/index.js CHANGED
@@ -816,7 +816,7 @@ function detectMediaType({
816
816
  var import_provider_utils2 = require("@ai-sdk/provider-utils");
817
817
 
818
818
  // src/version.ts
819
- var VERSION = true ? "5.0.251" : "0.0.0-test";
819
+ var VERSION = true ? "5.0.253" : "0.0.0-test";
820
820
 
821
821
  // src/util/download/download.ts
822
822
  var download = async ({
@@ -1353,7 +1353,7 @@ var jsonValueSchema = import_v42.z.lazy(
1353
1353
  import_v42.z.string(),
1354
1354
  import_v42.z.number(),
1355
1355
  import_v42.z.boolean(),
1356
- import_v42.z.record(import_v42.z.string(), jsonValueSchema),
1356
+ import_v42.z.record(import_v42.z.string(), jsonValueSchema.optional()),
1357
1357
  import_v42.z.array(jsonValueSchema)
1358
1358
  ])
1359
1359
  );
@@ -8669,6 +8669,9 @@ var CHUNKING_REGEXPS = {
8669
8669
  word: /\S+\s+/m,
8670
8670
  line: /\n+/m
8671
8671
  };
8672
+ function isDocumentHidden() {
8673
+ return typeof document !== "undefined" && document.visibilityState === "hidden";
8674
+ }
8672
8675
  function smoothStream({
8673
8676
  delayInMs = 10,
8674
8677
  chunking = "word",
@@ -8730,7 +8733,7 @@ function smoothStream({
8730
8733
  while ((match = detectChunk(buffer)) != null) {
8731
8734
  controller.enqueue({ type: "text-delta", text: match, id });
8732
8735
  buffer = buffer.slice(match.length);
8733
- await delay2(delayInMs);
8736
+ await delay2(isDocumentHidden() ? null : delayInMs);
8734
8737
  }
8735
8738
  }
8736
8739
  });