@mastra/hono 1.4.14-alpha.9 → 1.4.14

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.js CHANGED
@@ -6,7 +6,7 @@ import { ViewerRegistry, handleInputMessage } from '@mastra/server/browser-strea
6
6
 
7
7
  // src/index.ts
8
8
 
9
- // ../../node_modules/.pnpm/hono@4.12.14/node_modules/hono/dist/http-exception.js
9
+ // ../../node_modules/.pnpm/hono@4.12.18/node_modules/hono/dist/http-exception.js
10
10
  var HTTPException = class extends Error {
11
11
  res;
12
12
  status;
@@ -39,14 +39,8 @@ var HTTPException = class extends Error {
39
39
  }
40
40
  };
41
41
 
42
- // ../../node_modules/.pnpm/hono@4.12.14/node_modules/hono/dist/middleware/body-limit/index.js
42
+ // ../../node_modules/.pnpm/hono@4.12.18/node_modules/hono/dist/middleware/body-limit/index.js
43
43
  var ERROR_MESSAGE = "Payload Too Large";
44
- var BodyLimitError = class extends Error {
45
- constructor(message) {
46
- super(message);
47
- this.name = "BodyLimitError";
48
- }
49
- };
50
44
  var bodyLimit = (options) => {
51
45
  const onError = options.onError || (() => {
52
46
  const res = new Response(ERROR_MESSAGE, {
@@ -66,37 +60,36 @@ var bodyLimit = (options) => {
66
60
  return contentLength > maxSize ? onError(c) : next();
67
61
  }
68
62
  let size = 0;
63
+ const chunks = [];
69
64
  const rawReader = c.req.raw.body.getReader();
70
- const reader = new ReadableStream({
71
- async start(controller) {
72
- try {
73
- for (; ; ) {
74
- const { done, value } = await rawReader.read();
75
- if (done) {
76
- break;
77
- }
78
- size += value.length;
79
- if (size > maxSize) {
80
- controller.error(new BodyLimitError(ERROR_MESSAGE));
81
- break;
82
- }
83
- controller.enqueue(value);
65
+ for (; ; ) {
66
+ const { done, value } = await rawReader.read();
67
+ if (done) {
68
+ break;
69
+ }
70
+ size += value.length;
71
+ if (size > maxSize) {
72
+ return onError(c);
73
+ }
74
+ chunks.push(value);
75
+ }
76
+ const requestInit = {
77
+ body: new ReadableStream({
78
+ start(controller) {
79
+ for (const chunk of chunks) {
80
+ controller.enqueue(chunk);
84
81
  }
85
- } finally {
86
82
  controller.close();
87
83
  }
88
- }
89
- });
90
- const requestInit = { body: reader, duplex: "half" };
84
+ }),
85
+ duplex: "half"
86
+ };
91
87
  c.req.raw = new Request(c.req.raw, requestInit);
92
- await next();
93
- if (c.error instanceof BodyLimitError) {
94
- c.res = await onError(c);
95
- }
88
+ return next();
96
89
  };
97
90
  };
98
91
 
99
- // ../../node_modules/.pnpm/hono@4.12.14/node_modules/hono/dist/utils/stream.js
92
+ // ../../node_modules/.pnpm/hono@4.12.18/node_modules/hono/dist/utils/stream.js
100
93
  var StreamingApi = class {
101
94
  writer;
102
95
  encoder;
@@ -173,7 +166,7 @@ var StreamingApi = class {
173
166
  }
174
167
  };
175
168
 
176
- // ../../node_modules/.pnpm/hono@4.12.14/node_modules/hono/dist/helper/streaming/utils.js
169
+ // ../../node_modules/.pnpm/hono@4.12.18/node_modules/hono/dist/helper/streaming/utils.js
177
170
  var isOldBunVersion = () => {
178
171
  const version2 = typeof Bun !== "undefined" ? Bun.version : void 0;
179
172
  if (version2 === void 0) {
@@ -184,7 +177,7 @@ var isOldBunVersion = () => {
184
177
  return result;
185
178
  };
186
179
 
187
- // ../../node_modules/.pnpm/hono@4.12.14/node_modules/hono/dist/helper/streaming/stream.js
180
+ // ../../node_modules/.pnpm/hono@4.12.18/node_modules/hono/dist/helper/streaming/stream.js
188
181
  var contextStash = /* @__PURE__ */ new WeakMap();
189
182
  var stream = (c, cb, onError) => {
190
183
  const { readable, writable } = new TransformStream();