ai 5.0.251 → 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/CHANGELOG.md +11 -0
- package/dist/index.d.mts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +5 -2
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +5 -2
- package/dist/index.mjs.map +1 -1
- package/dist/internal/index.js +1 -1
- package/dist/internal/index.mjs +1 -1
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,16 @@
|
|
|
1
1
|
# ai
|
|
2
2
|
|
|
3
|
+
## 5.0.252
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 2c12cd3: fix(ai): skip `smoothStream` delays while the document is hidden
|
|
8
|
+
- Updated dependencies [cfa33a0]
|
|
9
|
+
- Updated dependencies [8ee6f7d]
|
|
10
|
+
- Updated dependencies [2287da5]
|
|
11
|
+
- Updated dependencies [526f371]
|
|
12
|
+
- @ai-sdk/gateway@2.0.146
|
|
13
|
+
|
|
3
14
|
## 5.0.251
|
|
4
15
|
|
|
5
16
|
### 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.
|
|
819
|
+
var VERSION = true ? "5.0.252" : "0.0.0-test";
|
|
820
820
|
|
|
821
821
|
// src/util/download/download.ts
|
|
822
822
|
var download = async ({
|
|
@@ -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
|
});
|