elysia 2.0.0-beta.21 → 2.0.0-beta.23
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/_virtual/_rolldown/runtime.mjs +1 -0
- package/dist/adapter/bun/index.d.ts +6 -8
- package/dist/adapter/bun/index.js +6 -8
- package/dist/adapter/bun/index.mjs +7 -8
- package/dist/adapter/constants.mjs +1 -0
- package/dist/adapter/default-headers.mjs +1 -0
- package/dist/adapter/index.mjs +1 -0
- package/dist/adapter/origin.mjs +1 -0
- package/dist/adapter/response-ownership.mjs +1 -0
- package/dist/adapter/skip-clone.mjs +1 -0
- package/dist/adapter/types.mjs +1 -0
- package/dist/adapter/utils.d.ts +5 -8
- package/dist/adapter/utils.js +24 -18
- package/dist/adapter/utils.mjs +25 -18
- package/dist/adapter/web-standard/handler.mjs +2 -1
- package/dist/adapter/web-standard/index.mjs +1 -0
- package/dist/adapter/web-standard/utils.mjs +1 -0
- package/dist/base.d.ts +118 -69
- package/dist/base.js +214 -194
- package/dist/base.mjs +221 -200
- package/dist/compile/aot-capture.js +2 -2
- package/dist/compile/aot-capture.mjs +4 -3
- package/dist/compile/aot-emit.js +7 -8
- package/dist/compile/aot-emit.mjs +8 -8
- package/dist/compile/aot-reconstruct.mjs +3 -2
- package/dist/compile/aot.d.ts +3 -3
- package/dist/compile/aot.js +5 -5
- package/dist/compile/aot.mjs +6 -5
- package/dist/compile/handler/descriptor.d.ts +2 -5
- package/dist/compile/handler/descriptor.js +12 -17
- package/dist/compile/handler/descriptor.mjs +16 -21
- package/dist/compile/handler/frozen-validator.d.ts +2 -2
- package/dist/compile/handler/frozen-validator.js +3 -3
- package/dist/compile/handler/frozen-validator.mjs +4 -3
- package/dist/compile/handler/index.d.ts +3 -1
- package/dist/compile/handler/index.js +78 -118
- package/dist/compile/handler/index.mjs +84 -125
- package/dist/compile/handler/jit.d.ts +12 -12
- package/dist/compile/handler/jit.js +60 -43
- package/dist/compile/handler/jit.mjs +63 -47
- package/dist/compile/handler/params.d.ts +5 -1
- package/dist/compile/handler/params.js +14 -5
- package/dist/compile/handler/params.mjs +16 -7
- package/dist/compile/handler/reconstruct.d.ts +2 -2
- package/dist/compile/handler/reconstruct.js +2 -2
- package/dist/compile/handler/reconstruct.mjs +3 -2
- package/dist/compile/handler/static-clone-resolver.mjs +1 -0
- package/dist/compile/handler/utils.d.ts +13 -7
- package/dist/compile/handler/utils.js +75 -52
- package/dist/compile/handler/utils.mjs +77 -54
- package/dist/compile/jit-probe.mjs +1 -0
- package/dist/compile/lexer.js +4 -4
- package/dist/compile/lexer.mjs +5 -4
- package/dist/compile/utils.d.ts +2 -1
- package/dist/compile/utils.js +8 -3
- package/dist/compile/utils.mjs +8 -3
- package/dist/compiled.mjs +1 -0
- package/dist/constants.mjs +1 -0
- package/dist/context.d.ts +1 -1
- package/dist/context.js +1 -0
- package/dist/context.mjs +3 -1
- package/dist/cookie/config.d.ts +2 -2
- package/dist/cookie/config.js +21 -26
- package/dist/cookie/config.mjs +22 -26
- package/dist/cookie/cookie.mjs +1 -0
- package/dist/cookie/crypto.mjs +1 -0
- package/dist/cookie/error.mjs +1 -0
- package/dist/cookie/lib.mjs +1 -0
- package/dist/cookie/serialize.mjs +1 -0
- package/dist/cookie/types.mjs +1 -0
- package/dist/cookie/utils.d.ts +1 -1
- package/dist/cookie/utils.js +64 -45
- package/dist/cookie/utils.mjs +66 -46
- package/dist/error.d.ts +10 -6
- package/dist/error.js +22 -6
- package/dist/error.mjs +25 -9
- package/dist/generation.mjs +1 -0
- package/dist/handler/error.d.ts +12 -15
- package/dist/handler/error.js +43 -40
- package/dist/handler/error.mjs +45 -41
- package/dist/handler/fetch.js +59 -21
- package/dist/handler/fetch.mjs +61 -22
- package/dist/handler/utils.d.ts +16 -3
- package/dist/handler/utils.js +14 -13
- package/dist/handler/utils.mjs +16 -15
- package/dist/index.d.ts +9 -9
- package/dist/index.js +1 -0
- package/dist/index.mjs +3 -2
- package/dist/memory.mjs +1 -0
- package/dist/package.js +1 -1
- package/dist/package.mjs +2 -1
- package/dist/parse-query.js +76 -76
- package/dist/parse-query.mjs +77 -76
- package/dist/plugin/aot/bun.mjs +1 -0
- package/dist/plugin/aot/core.d.ts +1 -1
- package/dist/plugin/aot/core.js +7 -4
- package/dist/plugin/aot/core.mjs +8 -5
- package/dist/plugin/aot/esbuild.mjs +1 -0
- package/dist/plugin/aot/rspack-loader.mjs +1 -0
- package/dist/plugin/aot/rspack.mjs +1 -0
- package/dist/plugin/aot/treeshake.mjs +1 -0
- package/dist/plugin/aot/unplugin.mjs +4 -3
- package/dist/plugin/aot/vite.mjs +1 -0
- package/dist/plugin/aot/worker.mjs +1 -0
- package/dist/plugin/auto-head.mjs +1 -0
- package/dist/plugin/trace.mjs +1 -0
- package/dist/plugin/websocket.mjs +1 -0
- package/dist/route-table.mjs +1 -0
- package/dist/schema-snapshot.js +28 -3
- package/dist/schema-snapshot.mjs +29 -3
- package/dist/sucrose.d.ts +2 -2
- package/dist/sucrose.js +11 -11
- package/dist/sucrose.mjs +12 -11
- package/dist/trace.js +8 -10
- package/dist/trace.mjs +10 -11
- package/dist/type/bridge-live.d.ts +1 -1
- package/dist/type/bridge-live.mjs +1 -0
- package/dist/type/bridge.d.ts +1 -1
- package/dist/type/bridge.mjs +1 -0
- package/dist/type/coerce-plan.mjs +1 -0
- package/dist/type/coerce.d.ts +1 -1
- package/dist/type/coerce.mjs +1 -0
- package/dist/type/compat.mjs +1 -0
- package/dist/type/constants.d.ts +1 -1
- package/dist/type/constants.mjs +1 -0
- package/dist/type/elysia/accelerate.mjs +1 -0
- package/dist/type/elysia/array-buffer.d.ts +3 -2
- package/dist/type/elysia/array-buffer.js +5 -5
- package/dist/type/elysia/array-buffer.mjs +6 -5
- package/dist/type/elysia/array-string.mjs +1 -0
- package/dist/type/elysia/array.mjs +1 -0
- package/dist/type/elysia/boolean-string.mjs +1 -0
- package/dist/type/elysia/boolean.mjs +1 -0
- package/dist/type/elysia/cookie.mjs +1 -0
- package/dist/type/elysia/date.mjs +1 -0
- package/dist/type/elysia/file-type.mjs +1 -0
- package/dist/type/elysia/file.mjs +1 -0
- package/dist/type/elysia/files.mjs +1 -0
- package/dist/type/elysia/form.mjs +1 -0
- package/dist/type/elysia/integer-string.mjs +1 -0
- package/dist/type/elysia/integer.mjs +1 -0
- package/dist/type/elysia/intersect.mjs +1 -0
- package/dist/type/elysia/json-string.mjs +1 -0
- package/dist/type/elysia/keep-config.js +8 -8
- package/dist/type/elysia/keep-config.mjs +9 -8
- package/dist/type/elysia/maybe-empty.mjs +1 -0
- package/dist/type/elysia/no-validate.mjs +1 -0
- package/dist/type/elysia/nullable.mjs +1 -0
- package/dist/type/elysia/number.mjs +1 -0
- package/dist/type/elysia/numeric-enum.d.ts +4 -2
- package/dist/type/elysia/numeric-enum.mjs +1 -0
- package/dist/type/elysia/numeric.mjs +1 -0
- package/dist/type/elysia/object-string.mjs +1 -0
- package/dist/type/elysia/object.mjs +1 -0
- package/dist/type/elysia/optional.mjs +1 -0
- package/dist/type/elysia/problem.mjs +1 -0
- package/dist/type/elysia/string.mjs +1 -0
- package/dist/type/elysia/uint8-array.d.ts +2 -1
- package/dist/type/elysia/uint8-array.js +2 -2
- package/dist/type/elysia/uint8-array.mjs +3 -2
- package/dist/type/elysia/union-enum.mjs +1 -0
- package/dist/type/elysia/union.mjs +1 -0
- package/dist/type/elysia/utils.js +3 -3
- package/dist/type/elysia/utils.mjs +4 -3
- package/dist/type/exports.mjs +1 -0
- package/dist/type/index.mjs +2 -1
- package/dist/type/shared.mjs +1 -0
- package/dist/type/sync-require.mjs +1 -0
- package/dist/type/typebox-system-lite.mjs +1 -0
- package/dist/type/typebox-system-require.mjs +1 -0
- package/dist/type/typebox-type-live.mjs +1 -0
- package/dist/type/typebox-value-live.mjs +1 -0
- package/dist/type/typebox-value-ops.mjs +1 -0
- package/dist/type/typebox-value.mjs +1 -0
- package/dist/type/types.d.ts +1 -1
- package/dist/type/types.mjs +1 -0
- package/dist/type/utils.mjs +1 -0
- package/dist/type/validator/clean-safe.mjs +1 -0
- package/dist/type/validator/custom-error.js +41 -33
- package/dist/type/validator/custom-error.mjs +42 -33
- package/dist/type/validator/default-precompute.d.ts +2 -2
- package/dist/type/validator/default-precompute.js +10 -11
- package/dist/type/validator/default-precompute.mjs +13 -13
- package/dist/type/validator/exact-mirror.mjs +1 -0
- package/dist/type/validator/frozen-check.js +7 -7
- package/dist/type/validator/frozen-check.mjs +8 -7
- package/dist/type/validator/index.d.ts +2 -2
- package/dist/type/validator/index.js +4 -8
- package/dist/type/validator/index.mjs +5 -8
- package/dist/type/validator/string-codec-aot.d.ts +1 -1
- package/dist/type/validator/string-codec-aot.mjs +1 -0
- package/dist/type/validator/validator-cache.js +18 -18
- package/dist/type/validator/validator-cache.mjs +19 -18
- package/dist/types.d.ts +108 -70
- package/dist/types.mjs +1 -0
- package/dist/universal/constants.mjs +1 -0
- package/dist/universal/file.mjs +1 -0
- package/dist/universal/index.mjs +1 -0
- package/dist/universal/is-production.mjs +1 -0
- package/dist/universal/server.mjs +1 -0
- package/dist/utils.d.ts +49 -31
- package/dist/utils.js +221 -109
- package/dist/utils.mjs +215 -106
- package/dist/validator/index.d.ts +3 -3
- package/dist/validator/index.js +4 -4
- package/dist/validator/index.mjs +5 -4
- package/dist/validator/route.d.ts +2 -2
- package/dist/validator/route.mjs +1 -0
- package/dist/ws/context.js +1 -1
- package/dist/ws/context.mjs +2 -1
- package/dist/ws/index.mjs +1 -0
- package/dist/ws/parser.mjs +1 -0
- package/dist/ws/route.js +34 -25
- package/dist/ws/route.mjs +40 -30
- package/dist/ws/types.d.ts +2 -3
- package/dist/ws/types.mjs +1 -0
- package/package.json +2 -2
|
@@ -7,14 +7,12 @@ type NativeRoutes = Record<string, Record<string, unknown>>;
|
|
|
7
7
|
/**
|
|
8
8
|
* HTML bundles served by Bun's native router.
|
|
9
9
|
*
|
|
10
|
-
* A `:param` / `*` bundle
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
* All or nothing: when any route cannot be expressed in Bun's router, dynamic
|
|
17
|
-
* bundles are not served natively at all, since that route would be shadowed.
|
|
10
|
+
* A `:param` / `*` bundle matches before `fetch`, so with a `handoff` every
|
|
11
|
+
* other route of that method is registered natively too, pointing at `fetch`;
|
|
12
|
+
* Bun's specificity (exact > param > wildcard) then picks the Elysia route over
|
|
13
|
+
* the bundle (Elysia's own router skips these bundles, see `#buildRouterUnsafe`).
|
|
14
|
+
* If any route can't be expressed in Bun's router, dynamic bundles are skipped
|
|
15
|
+
* entirely, since the bundle would shadow that route.
|
|
18
16
|
*/
|
|
19
17
|
declare function collectHTMLBundleRoutes(app: AnyElysia, handoff?: (request: Request, server: unknown) => unknown, routes?: NativeRoutes): NativeRoutes | undefined;
|
|
20
18
|
declare function collectStaticRoutes(app: AnyElysia): Record<string, Record<string, Response | BunHTMLBundlelike>> | undefined;
|
|
@@ -95,14 +95,12 @@ function isNativePath(path) {
|
|
|
95
95
|
/**
|
|
96
96
|
* HTML bundles served by Bun's native router.
|
|
97
97
|
*
|
|
98
|
-
* A `:param` / `*` bundle
|
|
99
|
-
*
|
|
100
|
-
*
|
|
101
|
-
*
|
|
102
|
-
*
|
|
103
|
-
*
|
|
104
|
-
* All or nothing: when any route cannot be expressed in Bun's router, dynamic
|
|
105
|
-
* bundles are not served natively at all, since that route would be shadowed.
|
|
98
|
+
* A `:param` / `*` bundle matches before `fetch`, so with a `handoff` every
|
|
99
|
+
* other route of that method is registered natively too, pointing at `fetch`;
|
|
100
|
+
* Bun's specificity (exact > param > wildcard) then picks the Elysia route over
|
|
101
|
+
* the bundle (Elysia's own router skips these bundles, see `#buildRouterUnsafe`).
|
|
102
|
+
* If any route can't be expressed in Bun's router, dynamic bundles are skipped
|
|
103
|
+
* entirely, since the bundle would shadow that route.
|
|
106
104
|
*/
|
|
107
105
|
function collectHTMLBundleRoutes(app, handoff, routes) {
|
|
108
106
|
let dynamic;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
// @bun
|
|
1
2
|
import { createAdapter } from "../index.mjs";
|
|
2
3
|
import { flattenChain, getLoosePath, isHTMLBundle, isSocketQuiet, nullObject, throwLifecycleErrors } from "../../utils.mjs";
|
|
3
4
|
import { preloadTypebox } from "../../type/bridge.mjs";
|
|
@@ -94,14 +95,12 @@ function isNativePath(path) {
|
|
|
94
95
|
/**
|
|
95
96
|
* HTML bundles served by Bun's native router.
|
|
96
97
|
*
|
|
97
|
-
* A `:param` / `*` bundle
|
|
98
|
-
*
|
|
99
|
-
*
|
|
100
|
-
*
|
|
101
|
-
*
|
|
102
|
-
*
|
|
103
|
-
* All or nothing: when any route cannot be expressed in Bun's router, dynamic
|
|
104
|
-
* bundles are not served natively at all, since that route would be shadowed.
|
|
98
|
+
* A `:param` / `*` bundle matches before `fetch`, so with a `handoff` every
|
|
99
|
+
* other route of that method is registered natively too, pointing at `fetch`;
|
|
100
|
+
* Bun's specificity (exact > param > wildcard) then picks the Elysia route over
|
|
101
|
+
* the bundle (Elysia's own router skips these bundles, see `#buildRouterUnsafe`).
|
|
102
|
+
* If any route can't be expressed in Bun's router, dynamic bundles are skipped
|
|
103
|
+
* entirely, since the bundle would shadow that route.
|
|
105
104
|
*/
|
|
106
105
|
function collectHTMLBundleRoutes(app, handoff, routes) {
|
|
107
106
|
let dynamic;
|
package/dist/adapter/index.mjs
CHANGED
package/dist/adapter/origin.mjs
CHANGED
package/dist/adapter/types.mjs
CHANGED
package/dist/adapter/utils.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { BaseCookie } from "../cookie/types.js";
|
|
2
1
|
import { StatusMap } from "../constants.js";
|
|
2
|
+
import { BaseCookie } from "../cookie/types.js";
|
|
3
3
|
import { Context } from "../context.js";
|
|
4
4
|
import { ElysiaFile } from "../universal/file.js";
|
|
5
5
|
import { HTTPHeaders } from "../types.js";
|
|
@@ -29,13 +29,10 @@ declare function streamResponse(response: Response): AsyncGenerator<any, void, a
|
|
|
29
29
|
declare function handleSet(set: Context['set']): void;
|
|
30
30
|
declare function createResponseHandler(handler: CreateHandlerParameter): (response: Response, set?: Context["set"], request?: Request, owned?: boolean) => any;
|
|
31
31
|
/**
|
|
32
|
-
*
|
|
33
|
-
*
|
|
34
|
-
*
|
|
35
|
-
*
|
|
36
|
-
* A returned `Response` is not observed, reading `.body` would move
|
|
37
|
-
* every Response on these routes off Bun's native send path; a `bytes()`
|
|
38
|
-
* stream keeps its exact-stream contract and releases early as before
|
|
32
|
+
* Tee a returned `ReadableStream` so afterResponse, `defer()` and derive
|
|
33
|
+
* dispose wait for it, as for a tee'd generator. A `bytes()` stream is left
|
|
34
|
+
* alone (exact-stream contract), and so is a `Response`: reading its `.body`
|
|
35
|
+
* would move it off Bun's native send path
|
|
39
36
|
*/
|
|
40
37
|
declare function observeStream(source: ReadableStream): [ReadableStream, AsyncIterable<unknown>, AsyncIterableIterator<unknown>] | undefined;
|
|
41
38
|
/**
|
package/dist/adapter/utils.js
CHANGED
|
@@ -132,8 +132,17 @@ function createStreamHandler({ mapResponse, mapCompactResponse }) {
|
|
|
132
132
|
const typedSSE = !skipFormat && "sse" in generator && generator.sse === true;
|
|
133
133
|
const sourceIterator = typeof generator.next === "function" ? generator : void 0;
|
|
134
134
|
let init = typedSSE ? void 0 : generator.next?.();
|
|
135
|
-
if (set) handleSet(set);
|
|
136
135
|
if (init instanceof Promise) init = await init;
|
|
136
|
+
const sign = set?.["~sign"];
|
|
137
|
+
if (sign) try {
|
|
138
|
+
await sign(set);
|
|
139
|
+
} catch (error) {
|
|
140
|
+
try {
|
|
141
|
+
await generator.return?.(void 0);
|
|
142
|
+
} catch {}
|
|
143
|
+
throw error;
|
|
144
|
+
}
|
|
145
|
+
if (set) handleSet(set);
|
|
137
146
|
const yieldedStream = init?.value instanceof ReadableStream;
|
|
138
147
|
if (yieldedStream) generator = init.value;
|
|
139
148
|
else if (init && (typeof init?.done === "undefined" || init?.done)) {
|
|
@@ -224,21 +233,21 @@ function createStreamHandler({ mapResponse, mapCompactResponse }) {
|
|
|
224
233
|
controller.enqueue(textEncoder.encode(value.toSSE()));
|
|
225
234
|
return;
|
|
226
235
|
}
|
|
227
|
-
|
|
228
|
-
if (value instanceof Blob) p = value.arrayBuffer().then((buffer) => {
|
|
236
|
+
if (value instanceof Blob) return value.arrayBuffer().then((buffer) => {
|
|
229
237
|
controller.enqueue(new Uint8Array(buffer));
|
|
230
238
|
});
|
|
231
|
-
|
|
239
|
+
if (value instanceof Uint8Array) {
|
|
232
240
|
controller.enqueue(value);
|
|
233
|
-
|
|
234
|
-
}
|
|
241
|
+
return;
|
|
242
|
+
}
|
|
243
|
+
if (value instanceof ArrayBuffer) {
|
|
235
244
|
controller.enqueue(new Uint8Array(value));
|
|
236
|
-
|
|
237
|
-
}
|
|
245
|
+
return;
|
|
246
|
+
}
|
|
247
|
+
if (ArrayBuffer.isView(value)) {
|
|
238
248
|
controller.enqueue(new Uint8Array(value.buffer, value.byteOffset, value.byteLength));
|
|
239
|
-
|
|
240
|
-
}
|
|
241
|
-
if (p !== false) return p === true ? void 0 : p;
|
|
249
|
+
return;
|
|
250
|
+
}
|
|
242
251
|
if (typeof value === "object") try {
|
|
243
252
|
controller.enqueue(textEncoder.encode(format(JSON.stringify(value))));
|
|
244
253
|
} catch {
|
|
@@ -422,13 +431,10 @@ const doneResult = {
|
|
|
422
431
|
value: void 0
|
|
423
432
|
};
|
|
424
433
|
/**
|
|
425
|
-
*
|
|
426
|
-
*
|
|
427
|
-
*
|
|
428
|
-
*
|
|
429
|
-
* A returned `Response` is not observed, reading `.body` would move
|
|
430
|
-
* every Response on these routes off Bun's native send path; a `bytes()`
|
|
431
|
-
* stream keeps its exact-stream contract and releases early as before
|
|
434
|
+
* Tee a returned `ReadableStream` so afterResponse, `defer()` and derive
|
|
435
|
+
* dispose wait for it, as for a tee'd generator. A `bytes()` stream is left
|
|
436
|
+
* alone (exact-stream contract), and so is a `Response`: reading its `.body`
|
|
437
|
+
* would move it off Bun's native send path
|
|
432
438
|
*/
|
|
433
439
|
function observeStream(source) {
|
|
434
440
|
if (source.locked || require_utils.isByteStream(source)) return;
|
package/dist/adapter/utils.mjs
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
// @bun
|
|
1
2
|
import { hasHeaderShorthand } from "../universal/constants.mjs";
|
|
2
3
|
import { StatusMap } from "../constants.mjs";
|
|
3
4
|
import { isByteStream, isNotEmpty, nullObject, sseData } from "../utils.mjs";
|
|
@@ -131,8 +132,17 @@ function createStreamHandler({ mapResponse, mapCompactResponse }) {
|
|
|
131
132
|
const typedSSE = !skipFormat && "sse" in generator && generator.sse === true;
|
|
132
133
|
const sourceIterator = typeof generator.next === "function" ? generator : void 0;
|
|
133
134
|
let init = typedSSE ? void 0 : generator.next?.();
|
|
134
|
-
if (set) handleSet(set);
|
|
135
135
|
if (init instanceof Promise) init = await init;
|
|
136
|
+
const sign = set?.["~sign"];
|
|
137
|
+
if (sign) try {
|
|
138
|
+
await sign(set);
|
|
139
|
+
} catch (error) {
|
|
140
|
+
try {
|
|
141
|
+
await generator.return?.(void 0);
|
|
142
|
+
} catch {}
|
|
143
|
+
throw error;
|
|
144
|
+
}
|
|
145
|
+
if (set) handleSet(set);
|
|
136
146
|
const yieldedStream = init?.value instanceof ReadableStream;
|
|
137
147
|
if (yieldedStream) generator = init.value;
|
|
138
148
|
else if (init && (typeof init?.done === "undefined" || init?.done)) {
|
|
@@ -223,21 +233,21 @@ function createStreamHandler({ mapResponse, mapCompactResponse }) {
|
|
|
223
233
|
controller.enqueue(textEncoder.encode(value.toSSE()));
|
|
224
234
|
return;
|
|
225
235
|
}
|
|
226
|
-
|
|
227
|
-
if (value instanceof Blob) p = value.arrayBuffer().then((buffer) => {
|
|
236
|
+
if (value instanceof Blob) return value.arrayBuffer().then((buffer) => {
|
|
228
237
|
controller.enqueue(new Uint8Array(buffer));
|
|
229
238
|
});
|
|
230
|
-
|
|
239
|
+
if (value instanceof Uint8Array) {
|
|
231
240
|
controller.enqueue(value);
|
|
232
|
-
|
|
233
|
-
}
|
|
241
|
+
return;
|
|
242
|
+
}
|
|
243
|
+
if (value instanceof ArrayBuffer) {
|
|
234
244
|
controller.enqueue(new Uint8Array(value));
|
|
235
|
-
|
|
236
|
-
}
|
|
245
|
+
return;
|
|
246
|
+
}
|
|
247
|
+
if (ArrayBuffer.isView(value)) {
|
|
237
248
|
controller.enqueue(new Uint8Array(value.buffer, value.byteOffset, value.byteLength));
|
|
238
|
-
|
|
239
|
-
}
|
|
240
|
-
if (p !== false) return p === true ? void 0 : p;
|
|
249
|
+
return;
|
|
250
|
+
}
|
|
241
251
|
if (typeof value === "object") try {
|
|
242
252
|
controller.enqueue(textEncoder.encode(format(JSON.stringify(value))));
|
|
243
253
|
} catch {
|
|
@@ -421,13 +431,10 @@ const doneResult = {
|
|
|
421
431
|
value: void 0
|
|
422
432
|
};
|
|
423
433
|
/**
|
|
424
|
-
*
|
|
425
|
-
*
|
|
426
|
-
*
|
|
427
|
-
*
|
|
428
|
-
* A returned `Response` is not observed, reading `.body` would move
|
|
429
|
-
* every Response on these routes off Bun's native send path; a `bytes()`
|
|
430
|
-
* stream keeps its exact-stream contract and releases early as before
|
|
434
|
+
* Tee a returned `ReadableStream` so afterResponse, `defer()` and derive
|
|
435
|
+
* dispose wait for it, as for a tee'd generator. A `bytes()` stream is left
|
|
436
|
+
* alone (exact-stream contract), and so is a `Response`: reading its `.body`
|
|
437
|
+
* would move it off Bun's native send path
|
|
431
438
|
*/
|
|
432
439
|
function observeStream(source) {
|
|
433
440
|
if (source.locked || isByteStream(source)) return;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
// @bun
|
|
1
2
|
import { isBun } from "../../universal/constants.mjs";
|
|
2
3
|
import { ElysiaFile } from "../../universal/file.mjs";
|
|
3
4
|
import { formToFormData, isElysiaForm, isNotEmpty, nullObject } from "../../utils.mjs";
|
|
@@ -69,7 +70,7 @@ const checkRemovedSetRedirect = !isProduction();
|
|
|
69
70
|
function mapResponse(response, set, request, owned) {
|
|
70
71
|
if (checkRemovedSetRedirect && Object.hasOwn(set, "redirect") && !isProduction()) {
|
|
71
72
|
delete set.redirect;
|
|
72
|
-
throw new Error("[Elysia] set.redirect was removed in 2.0
|
|
73
|
+
throw new Error("[Elysia] set.redirect was removed in 2.0 \u2014 return redirect(url) instead");
|
|
73
74
|
}
|
|
74
75
|
const headers = set.headers;
|
|
75
76
|
if (set.status !== void 0 || set.cookie || headers["\0"] === headers || isNotEmpty(headers)) return mapResponseWithSet(response, set, request, owned);
|