ai 6.0.293 → 6.0.294
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 +9 -0
- package/dist/index.js +26 -3
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +26 -3
- package/dist/index.mjs.map +1 -1
- package/dist/internal/index.js +1 -1
- package/dist/internal/index.mjs +1 -1
- package/docs/03-ai-sdk-core/36-transcription.mdx +1 -0
- package/package.json +4 -4
- package/src/util/write-to-server-response.ts +41 -2
package/dist/index.mjs
CHANGED
|
@@ -1224,7 +1224,7 @@ import {
|
|
|
1224
1224
|
} from "@ai-sdk/provider-utils";
|
|
1225
1225
|
|
|
1226
1226
|
// src/version.ts
|
|
1227
|
-
var VERSION = true ? "6.0.
|
|
1227
|
+
var VERSION = true ? "6.0.294" : "0.0.0-test";
|
|
1228
1228
|
|
|
1229
1229
|
// src/util/download/download.ts
|
|
1230
1230
|
var download = async ({
|
|
@@ -5575,21 +5575,44 @@ function writeToServerResponse({
|
|
|
5575
5575
|
response.writeHead(statusCode, headers);
|
|
5576
5576
|
}
|
|
5577
5577
|
const reader = stream.getReader();
|
|
5578
|
+
let clientDisconnected = false;
|
|
5579
|
+
let onDisconnect;
|
|
5580
|
+
const handleClose = () => {
|
|
5581
|
+
if (response.writableFinished) {
|
|
5582
|
+
return;
|
|
5583
|
+
}
|
|
5584
|
+
clientDisconnected = true;
|
|
5585
|
+
onDisconnect == null ? void 0 : onDisconnect();
|
|
5586
|
+
reader.cancel(new Error("Client disconnected.")).catch(() => {
|
|
5587
|
+
});
|
|
5588
|
+
};
|
|
5589
|
+
response.once("close", handleClose);
|
|
5590
|
+
if (response.destroyed) {
|
|
5591
|
+
handleClose();
|
|
5592
|
+
}
|
|
5578
5593
|
const read = async () => {
|
|
5579
5594
|
try {
|
|
5580
5595
|
while (true) {
|
|
5581
5596
|
const { done, value } = await reader.read();
|
|
5582
|
-
if (done)
|
|
5597
|
+
if (done || clientDisconnected || response.destroyed)
|
|
5583
5598
|
break;
|
|
5584
5599
|
const canContinue = response.write(value);
|
|
5585
5600
|
if (!canContinue) {
|
|
5586
5601
|
await new Promise((resolve3) => {
|
|
5602
|
+
onDisconnect = resolve3;
|
|
5587
5603
|
response.once("drain", resolve3);
|
|
5588
5604
|
});
|
|
5605
|
+
onDisconnect = void 0;
|
|
5589
5606
|
}
|
|
5590
5607
|
}
|
|
5591
5608
|
} finally {
|
|
5592
|
-
response.
|
|
5609
|
+
response.off("close", handleClose);
|
|
5610
|
+
if (clientDisconnected || response.destroyed) {
|
|
5611
|
+
reader.cancel().catch(() => {
|
|
5612
|
+
});
|
|
5613
|
+
} else {
|
|
5614
|
+
response.end();
|
|
5615
|
+
}
|
|
5593
5616
|
}
|
|
5594
5617
|
};
|
|
5595
5618
|
return read();
|