ai 5.0.250 → 5.0.252

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
@@ -727,7 +727,7 @@ import {
727
727
  } from "@ai-sdk/provider-utils";
728
728
 
729
729
  // src/version.ts
730
- var VERSION = true ? "5.0.250" : "0.0.0-test";
730
+ var VERSION = true ? "5.0.252" : "0.0.0-test";
731
731
 
732
732
  // src/util/download/download.ts
733
733
  var download = async ({
@@ -8630,6 +8630,9 @@ var CHUNKING_REGEXPS = {
8630
8630
  word: /\S+\s+/m,
8631
8631
  line: /\n+/m
8632
8632
  };
8633
+ function isDocumentHidden() {
8634
+ return typeof document !== "undefined" && document.visibilityState === "hidden";
8635
+ }
8633
8636
  function smoothStream({
8634
8637
  delayInMs = 10,
8635
8638
  chunking = "word",
@@ -8691,7 +8694,7 @@ function smoothStream({
8691
8694
  while ((match = detectChunk(buffer)) != null) {
8692
8695
  controller.enqueue({ type: "text-delta", text: match, id });
8693
8696
  buffer = buffer.slice(match.length);
8694
- await delay2(delayInMs);
8697
+ await delay2(isDocumentHidden() ? null : delayInMs);
8695
8698
  }
8696
8699
  }
8697
8700
  });