Files
SnowLuma/.pnpm-store/v11/files/3f/ce5a9fdda852bce195118bc222f42824f06f4f6216cebe8465434f1842509b42a60e3addf241a541c649dd33c6b8ee74c1bd35e105f28940f0a00e939c4f23
T
TanTan 2a69b23b47
Dev Build / cleanup (push) Canceled after 0s
Dev Build / typecheck (push) Canceled after 0s
Dev Build / build (linux-arm64, ubuntu-24.04-arm, linux-arm64) (push) Canceled after 0s
Dev Build / build (linux-x64, ubuntu-latest, linux-x64) (push) Canceled after 0s
Dev Build / build (win-x64, windows-latest, win32-x64) (push) Canceled after 0s
Dev Build / dispatch-dev-docker (push) Canceled after 0s
docs: 仓库链接指向本镜像仓库
2026-11-13 09:27:07 +08:00

27 lines
964 B
Plaintext

Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
const require_utils_stream = require("../../utils/stream.js");
const require_helper_streaming_utils = require("./utils.js");
//#region src/helper/streaming/stream.ts
const contextStash = /* @__PURE__ */ new WeakMap();
const stream = (c, cb, onError) => {
const { readable, writable } = new TransformStream();
const stream = new require_utils_stream.StreamingApi(writable, readable);
if (require_helper_streaming_utils.isOldBunVersion()) c.req.raw.signal.addEventListener("abort", () => {
if (!stream.closed) stream.abort();
});
contextStash.set(stream.responseReadable, c);
(async () => {
try {
await cb(stream);
} catch (e) {
if (e === void 0) {} else if (e instanceof Error && onError) await onError(e, stream);
else console.error(e);
} finally {
stream.close();
}
})();
return c.newResponse(stream.responseReadable);
};
//#endregion
exports.stream = stream;