elysia 2.0.0-exp.3 → 2.0.0-exp.31
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.js +0 -14
- package/dist/_virtual/_rolldown/runtime.mjs +2 -0
- package/dist/adapter/bun/index.d.ts +2 -25
- package/dist/adapter/bun/index.js +69 -24
- package/dist/adapter/bun/index.mjs +70 -25
- package/dist/adapter/constants.d.ts +3 -26
- package/dist/adapter/index.d.ts +1 -26
- package/dist/adapter/index.js +1 -17
- package/dist/adapter/index.mjs +1 -17
- package/dist/adapter/skip-clone.d.ts +4 -0
- package/dist/adapter/skip-clone.js +7 -0
- package/dist/adapter/skip-clone.mjs +5 -0
- package/dist/adapter/types.d.ts +7 -0
- package/dist/adapter/utils.d.ts +14 -12
- package/dist/adapter/utils.js +261 -140
- package/dist/adapter/utils.mjs +260 -140
- package/dist/adapter/web-standard/handler.js +27 -20
- package/dist/adapter/web-standard/handler.mjs +28 -21
- package/dist/adapter/web-standard/index.d.ts +2 -26
- package/dist/adapter/web-standard/index.js +35 -2
- package/dist/adapter/web-standard/index.mjs +35 -2
- package/dist/adapter/web-standard/utils.js +1 -0
- package/dist/adapter/web-standard/utils.mjs +1 -0
- package/dist/base.d.ts +144 -360
- package/dist/base.js +458 -220
- package/dist/base.mjs +459 -221
- package/dist/compile/aot.d.ts +45 -3
- package/dist/compile/aot.js +92 -3
- package/dist/compile/aot.mjs +89 -3
- package/dist/compile/handler/frozen-validator.d.ts +29 -0
- package/dist/compile/handler/frozen-validator.js +177 -0
- package/dist/compile/handler/frozen-validator.mjs +174 -0
- package/dist/compile/handler/index.d.ts +8 -5
- package/dist/compile/handler/index.js +155 -478
- package/dist/compile/handler/index.mjs +154 -480
- package/dist/compile/handler/jit.d.ts +34 -0
- package/dist/compile/handler/jit.js +474 -0
- package/dist/compile/handler/jit.mjs +472 -0
- package/dist/compile/handler/params.js +8 -2
- package/dist/compile/handler/params.mjs +9 -3
- package/dist/compile/handler/reconstruct.d.ts +12 -0
- package/dist/compile/handler/reconstruct.js +37 -0
- package/dist/compile/handler/reconstruct.mjs +36 -0
- package/dist/compile/handler/utils.d.ts +7 -11
- package/dist/compile/handler/utils.js +55 -116
- package/dist/compile/handler/utils.mjs +43 -102
- package/dist/compile/jit-probe.d.ts +17 -0
- package/dist/compile/jit-probe.js +30 -0
- package/dist/compile/jit-probe.mjs +28 -0
- package/dist/compile/lexer.d.ts +7 -0
- package/dist/compile/lexer.js +53 -0
- package/dist/compile/lexer.mjs +48 -0
- package/dist/compile/utils.js +2 -2
- package/dist/compile/utils.mjs +2 -2
- package/dist/constants.d.ts +4 -1
- package/dist/constants.js +19 -5
- package/dist/constants.mjs +17 -5
- package/dist/context.d.ts +1 -1
- package/dist/context.js +1 -1
- package/dist/context.mjs +1 -1
- package/dist/cookie/config.js +5 -5
- package/dist/cookie/config.mjs +5 -5
- package/dist/cookie/cookie.d.ts +2 -4
- package/dist/cookie/cookie.js +37 -23
- package/dist/cookie/cookie.mjs +37 -23
- package/dist/cookie/error.d.ts +17 -0
- package/dist/cookie/error.js +25 -0
- package/dist/cookie/error.mjs +24 -0
- package/dist/cookie/index.d.ts +5 -3
- package/dist/cookie/index.js +4 -1
- package/dist/cookie/index.mjs +4 -2
- package/dist/cookie/lib.js +12 -2
- package/dist/cookie/lib.mjs +12 -2
- package/dist/cookie/serialize.d.ts +6 -0
- package/dist/cookie/serialize.js +32 -0
- package/dist/cookie/serialize.mjs +31 -0
- package/dist/cookie/types.d.ts +1 -3
- package/dist/cookie/utils.d.ts +12 -2
- package/dist/cookie/utils.js +128 -39
- package/dist/cookie/utils.mjs +124 -40
- package/dist/error.d.ts +75 -17
- package/dist/error.js +263 -88
- package/dist/error.mjs +257 -88
- package/dist/handler/error.js +35 -4
- package/dist/handler/error.mjs +36 -5
- package/dist/handler/fetch.js +121 -88
- package/dist/handler/fetch.mjs +123 -90
- package/dist/handler/utils.d.ts +1 -1
- package/dist/handler/utils.js +8 -2
- package/dist/handler/utils.mjs +8 -2
- package/dist/index.d.ts +17 -11
- package/dist/index.js +15 -6
- package/dist/index.mjs +9 -7
- package/dist/memory.js +1 -1
- package/dist/memory.mjs +1 -1
- package/dist/parse-query.js +37 -22
- package/dist/parse-query.mjs +37 -22
- package/dist/plugin/bun.d.ts +2 -0
- package/dist/plugin/bun.js +12 -45
- package/dist/plugin/bun.mjs +13 -45
- package/dist/plugin/core.d.ts +150 -6
- package/dist/plugin/core.js +361 -5
- package/dist/plugin/core.mjs +356 -6
- package/dist/plugin/esbuild.d.ts +2 -0
- package/dist/plugin/esbuild.js +12 -42
- package/dist/plugin/esbuild.mjs +13 -43
- package/dist/plugin/source.d.ts +47 -5
- package/dist/plugin/source.js +90 -10
- package/dist/plugin/source.mjs +87 -10
- package/dist/plugin/treeshake.js +64 -16
- package/dist/plugin/treeshake.mjs +64 -16
- package/dist/plugin/vite.d.ts +2 -1
- package/dist/plugin/vite.js +41 -5
- package/dist/plugin/vite.mjs +42 -6
- package/dist/sucrose.d.ts +1 -23
- package/dist/sucrose.js +88 -52
- package/dist/sucrose.mjs +89 -51
- package/dist/trace.d.ts +22 -56
- package/dist/trace.js +261 -147
- package/dist/trace.mjs +260 -147
- package/dist/type/bridge-live.d.ts +14 -0
- package/dist/type/bridge-live.js +34 -0
- package/dist/type/bridge-live.mjs +16 -0
- package/dist/type/bridge.d.ts +11 -9
- package/dist/type/bridge.js +8 -0
- package/dist/type/bridge.mjs +3 -1
- package/dist/type/coerce-plan.d.ts +37 -0
- package/dist/type/coerce-plan.js +103 -0
- package/dist/type/coerce-plan.mjs +96 -0
- package/dist/type/coerce.d.ts +4 -18
- package/dist/type/coerce.js +37 -52
- package/dist/type/coerce.mjs +35 -50
- package/dist/type/compat.js +3 -2
- package/dist/type/compat.mjs +4 -3
- package/dist/type/elysia/array-buffer.d.ts +1 -2
- package/dist/type/elysia/array-buffer.js +7 -1
- package/dist/type/elysia/array-buffer.mjs +8 -2
- package/dist/type/elysia/array.js +7 -4
- package/dist/type/elysia/array.mjs +7 -4
- package/dist/type/elysia/boolean.js +6 -3
- package/dist/type/elysia/boolean.mjs +6 -3
- package/dist/type/elysia/date.js +38 -7
- package/dist/type/elysia/date.mjs +39 -8
- package/dist/type/elysia/file-type.d.ts +1 -1
- package/dist/type/elysia/file-type.js +5 -11
- package/dist/type/elysia/file-type.mjs +5 -11
- package/dist/type/elysia/file.js +7 -1
- package/dist/type/elysia/file.mjs +8 -2
- package/dist/type/elysia/files.js +13 -3
- package/dist/type/elysia/files.mjs +15 -5
- package/dist/type/elysia/integer.js +6 -3
- package/dist/type/elysia/integer.mjs +6 -3
- package/dist/type/elysia/intersect.js +8 -5
- package/dist/type/elysia/intersect.mjs +7 -4
- package/dist/type/elysia/maybe-empty.js +4 -2
- package/dist/type/elysia/maybe-empty.mjs +5 -3
- package/dist/type/elysia/nullable.js +4 -1
- package/dist/type/elysia/nullable.mjs +5 -2
- package/dist/type/elysia/number.js +6 -3
- package/dist/type/elysia/number.mjs +6 -3
- package/dist/type/elysia/numeric.js +1 -1
- package/dist/type/elysia/numeric.mjs +1 -1
- package/dist/type/elysia/object.js +8 -5
- package/dist/type/elysia/object.mjs +8 -5
- package/dist/type/elysia/optional.js +11 -13
- package/dist/type/elysia/optional.mjs +12 -13
- package/dist/type/elysia/string.js +6 -3
- package/dist/type/elysia/string.mjs +6 -3
- package/dist/type/elysia/uint8-array.d.ts +1 -2
- package/dist/type/elysia/uint8-array.js +7 -1
- package/dist/type/elysia/uint8-array.mjs +8 -2
- package/dist/type/elysia/union-enum.js +3 -2
- package/dist/type/elysia/union-enum.mjs +4 -3
- package/dist/type/elysia/union.js +6 -3
- package/dist/type/elysia/union.mjs +6 -3
- package/dist/type/elysia/utils.d.ts +2 -2
- package/dist/type/elysia/utils.js +11 -29
- package/dist/type/elysia/utils.mjs +11 -29
- package/dist/type/exports.js +6 -2073
- package/dist/type/exports.mjs +3 -323
- package/dist/type/index.d.ts +6 -2
- package/dist/type/index.js +64 -2
- package/dist/type/index.mjs +62 -3
- package/dist/type/types.d.ts +1 -1
- package/dist/type/utils.js +0 -18
- package/dist/type/utils.mjs +0 -18
- package/dist/type/validator/clean-safe.d.ts +7 -0
- package/dist/type/validator/clean-safe.js +73 -0
- package/dist/type/validator/clean-safe.mjs +68 -0
- package/dist/type/validator/default-precompute.d.ts +12 -3
- package/dist/type/validator/default-precompute.js +296 -22
- package/dist/type/validator/default-precompute.mjs +291 -22
- package/dist/type/validator/index.d.ts +2 -2
- package/dist/type/validator/index.js +112 -73
- package/dist/type/validator/index.mjs +113 -74
- package/dist/type/validator/string-codec-aot.d.ts +1 -2
- package/dist/type/validator/string-codec-aot.js +2 -43
- package/dist/type/validator/string-codec-aot.mjs +1 -42
- package/dist/type/validator/validator-cache.d.ts +3 -3
- package/dist/type/validator/validator-cache.js +24 -33
- package/dist/type/validator/validator-cache.mjs +24 -33
- package/dist/types.d.ts +61 -66
- package/dist/universal/constants.d.ts +1 -3
- package/dist/universal/constants.js +1 -5
- package/dist/universal/constants.mjs +1 -3
- package/dist/universal/file.d.ts +4 -1
- package/dist/universal/file.js +43 -30
- package/dist/universal/file.mjs +43 -30
- package/dist/universal/server.d.ts +1 -0
- package/dist/utils.d.ts +15 -4
- package/dist/utils.js +111 -19
- package/dist/utils.mjs +105 -20
- package/dist/validator/index.d.ts +8 -7
- package/dist/validator/index.js +100 -48
- package/dist/validator/index.mjs +101 -49
- package/dist/validator/route.d.ts +0 -1
- package/dist/validator/route.js +1 -1
- package/dist/validator/route.mjs +1 -1
- package/dist/ws/context.d.ts +1 -0
- package/dist/ws/context.js +12 -25
- package/dist/ws/context.mjs +12 -25
- package/dist/ws/parser.d.ts +1 -4
- package/dist/ws/route.d.ts +5 -2
- package/dist/ws/route.js +180 -63
- package/dist/ws/route.mjs +180 -65
- package/package.json +18 -5
- package/dist/adapter/bun/router.d.ts +0 -10
- package/dist/adapter/bun/router.js +0 -86
- package/dist/adapter/bun/router.mjs +0 -83
- package/dist/compile/handler/constants.d.ts +0 -1
- package/dist/compile/handler/constants.js +0 -1
- package/dist/compile/handler/constants.mjs +0 -1
- package/dist/compile/index.d.ts +0 -3
- package/dist/compile/index.js +0 -8
- package/dist/compile/index.mjs +0 -4
- package/dist/compile/types.d.ts +0 -4
- package/dist/compile/types.js +0 -1
- package/dist/compile/types.mjs +0 -1
- package/dist/universal/types.d.ts +0 -127
- package/dist/universal/types.js +0 -20
- package/dist/universal/types.mjs +0 -17
|
@@ -5,19 +5,6 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
|
5
5
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
6
|
var __getProtoOf = Object.getPrototypeOf;
|
|
7
7
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
-
var __exportAll = (all, no_symbols) => {
|
|
9
|
-
let target = {};
|
|
10
|
-
for (var name in all) {
|
|
11
|
-
__defProp(target, name, {
|
|
12
|
-
get: all[name],
|
|
13
|
-
enumerable: true
|
|
14
|
-
});
|
|
15
|
-
}
|
|
16
|
-
if (!no_symbols) {
|
|
17
|
-
__defProp(target, Symbol.toStringTag, { value: "Module" });
|
|
18
|
-
}
|
|
19
|
-
return target;
|
|
20
|
-
};
|
|
21
8
|
var __copyProps = (to, from, except, desc) => {
|
|
22
9
|
if (from && typeof from === "object" || typeof from === "function") {
|
|
23
10
|
for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
@@ -39,5 +26,4 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
39
26
|
|
|
40
27
|
//#endregion
|
|
41
28
|
|
|
42
|
-
exports.__exportAll = __exportAll;
|
|
43
29
|
exports.__toESM = __toESM;
|
|
@@ -1,30 +1,7 @@
|
|
|
1
|
-
import { ListenCallback, Serve } from "../../universal/server.js";
|
|
2
|
-
import { AnyLocalHook, MaybePromise } from "../../types.js";
|
|
3
|
-
import { Context } from "../../context.js";
|
|
4
1
|
import { AnyElysia } from "../../base.js";
|
|
2
|
+
import { ElysiaAdapterOptions } from "../types.js";
|
|
5
3
|
//#region src/adapter/bun/index.d.ts
|
|
6
4
|
declare function collectStaticRoutes(app: AnyElysia): readonly [Record<string, Record<string, Response>>, Promise<void>[]] | undefined;
|
|
7
|
-
declare const BunAdapter:
|
|
8
|
-
parse: {
|
|
9
|
-
default: (context: Context, contentType: string) => string | ArrayBuffer | unknown[] | Record<string, unknown> | Promise<unknown[] | Record<string | number | symbol, undefined>> | Promise<ArrayBuffer> | Promise<Record<string, unknown>> | Promise<string> | undefined;
|
|
10
|
-
json: (context: Context) => MaybePromise<Record<keyof any, undefined> | unknown[]>;
|
|
11
|
-
text: (context: Context) => MaybePromise<string>;
|
|
12
|
-
urlencoded: (context: Context) => MaybePromise<Record<string, string | string[]>>;
|
|
13
|
-
arrayBuffer: (context: Context) => MaybePromise<ArrayBuffer>;
|
|
14
|
-
formData: (context: Context) => MaybePromise<Record<string, unknown>>;
|
|
15
|
-
};
|
|
16
|
-
name: string;
|
|
17
|
-
runtime: "node" | "deno" | "bun" | "cloudflare-worker" | "browser" | "vercel" | "netlify" | "lambda" | "fastly" | "edge" | "unknown" | (string & {});
|
|
18
|
-
isWebStandard: boolean;
|
|
19
|
-
listen?(app: AnyElysia, options: string | number | Partial<Serve>, callback?: ListenCallback): void;
|
|
20
|
-
stop?(app: AnyElysia, closeActiveConnections?: boolean): Promise<void>;
|
|
21
|
-
response: {
|
|
22
|
-
map(response: unknown, set: Context["set"], ...params: unknown[]): unknown;
|
|
23
|
-
compact?(response: unknown, ...params: unknown[]): unknown;
|
|
24
|
-
static?(handle: unknown, hooks: AnyLocalHook, setHeaders?: Context["set"]["headers"], ...params: unknown[]): (() => unknown) | undefined;
|
|
25
|
-
nativeStatic?(handle: unknown, hooks: AnyLocalHook, set?: Context["set"]): (() => MaybePromise<Response>) | undefined;
|
|
26
|
-
};
|
|
27
|
-
fetch?(app: AnyElysia): (request: Request) => MaybePromise<Response>;
|
|
28
|
-
};
|
|
5
|
+
declare const BunAdapter: ElysiaAdapterOptions;
|
|
29
6
|
//#endregion
|
|
30
7
|
export { BunAdapter, collectStaticRoutes };
|
|
@@ -1,51 +1,96 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
2
|
const require_adapter_index = require('../index.js');
|
|
3
|
+
const require_constants = require('../../constants.js');
|
|
3
4
|
const require_utils = require('../../utils.js');
|
|
4
5
|
const require_adapter_web_standard_index = require('../web-standard/index.js');
|
|
6
|
+
const require_compile_handler_index = require('../../compile/handler/index.js');
|
|
5
7
|
const require_memory = require('../../memory.js');
|
|
6
8
|
const require_ws_route = require('../../ws/route.js');
|
|
7
9
|
|
|
8
10
|
//#region src/adapter/bun/index.ts
|
|
9
11
|
function collectStaticRoutes(app) {
|
|
10
|
-
if (app["~
|
|
11
|
-
const hook = require_utils.flattenChain(app["~hookChain"]);
|
|
12
|
-
if (hook && (hook?.request?.length || hook?.mapResponse?.length || hook?.afterResponse?.length || hook?.trace?.length)) return;
|
|
12
|
+
if (app["~config"]?.nativeStaticResponse === false) return;
|
|
13
13
|
app.fetch;
|
|
14
|
-
const
|
|
15
|
-
if (
|
|
14
|
+
const fetchLevelHook = require_utils.flattenChain(app["~hookChain"]);
|
|
15
|
+
if (fetchLevelHook?.request?.length || fetchLevelHook?.trace?.length || app["~ext"]?.hoc?.length) return;
|
|
16
|
+
const history = app.history;
|
|
17
|
+
if (!history?.length) return;
|
|
16
18
|
const ready = require_utils.nullObject();
|
|
17
19
|
const pending = [];
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
20
|
+
const strictPath = app["~config"]?.strictPath === true;
|
|
21
|
+
const seen = /* @__PURE__ */ new Map();
|
|
22
|
+
for (let i = 0; i < history.length; i++) {
|
|
23
|
+
const route = history[i];
|
|
24
|
+
const method = route[0] === "WS" ? "WS" : require_utils.mapMethodBack(route[0]);
|
|
25
|
+
seen.set(method + " " + route[1], i);
|
|
26
|
+
}
|
|
27
|
+
let explicitPaths;
|
|
28
|
+
if (!strictPath) {
|
|
29
|
+
explicitPaths = /* @__PURE__ */ new Map();
|
|
30
|
+
for (let i = 0; i < history.length; i++) {
|
|
31
|
+
const route = history[i];
|
|
32
|
+
const method = route[0] === "WS" ? "WS" : require_utils.mapMethodBack(route[0]);
|
|
33
|
+
const path = route[1];
|
|
34
|
+
let set = explicitPaths.get(method);
|
|
35
|
+
if (!set) explicitPaths.set(method, set = /* @__PURE__ */ new Set());
|
|
36
|
+
set.add(path);
|
|
37
|
+
if (require_constants.needEncodeRegex.test(path)) {
|
|
38
|
+
const encoded = encodeURI(path);
|
|
39
|
+
if (encoded !== path) set.add(encoded);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
const add = (method, path, value) => {
|
|
44
|
+
if (require_constants.needEncodeRegex.test(path)) path = encodeURI(path);
|
|
45
|
+
if (value instanceof Promise) pending.push(value.then((resolved) => {
|
|
46
|
+
if (resolved instanceof Response) (ready[path] ??= require_utils.nullObject())[method] = resolved;
|
|
47
|
+
}, (err) => {
|
|
48
|
+
console.error(`[Elysia] Static route ${method} ${path} failed to resolve:`, err);
|
|
49
|
+
}));
|
|
50
|
+
else (ready[path] ??= require_utils.nullObject())[method] = value;
|
|
51
|
+
};
|
|
52
|
+
for (let i = 0; i < history.length; i++) {
|
|
53
|
+
const route = history[i];
|
|
54
|
+
if (route[0] === "WS") continue;
|
|
55
|
+
const method = require_utils.mapMethodBack(route[0]);
|
|
56
|
+
const path = route[1];
|
|
57
|
+
if (seen.get(method + " " + path) !== i) continue;
|
|
58
|
+
const value = require_compile_handler_index.buildNativeStaticResponse(route, app);
|
|
59
|
+
if (!value) continue;
|
|
60
|
+
add(method, path, value);
|
|
61
|
+
if (!strictPath && !require_constants.isDynamicRegex.test(path)) {
|
|
62
|
+
const loose = require_utils.getLoosePath(path);
|
|
63
|
+
if (loose !== path && !explicitPaths?.get(method)?.has(loose)) add(method, loose, value);
|
|
29
64
|
}
|
|
30
65
|
}
|
|
66
|
+
if (!Object.keys(ready).length && !pending.length) return;
|
|
31
67
|
return [ready, pending];
|
|
32
68
|
}
|
|
33
69
|
const BunAdapter = require_adapter_index.createAdapter({
|
|
34
|
-
...require_adapter_web_standard_index.WebStandardAdapter,
|
|
35
70
|
name: "bun",
|
|
36
71
|
runtime: "bun",
|
|
72
|
+
isWebStandard: true,
|
|
73
|
+
parse: require_adapter_web_standard_index.WebStandardAdapter.parse,
|
|
74
|
+
response: require_adapter_web_standard_index.WebStandardAdapter.response,
|
|
37
75
|
listen(app, options, callback) {
|
|
38
76
|
const _config = app["~config"]?.serve;
|
|
39
|
-
const
|
|
77
|
+
const optionsIsObject = typeof options === "object";
|
|
78
|
+
const _options = optionsIsObject ? { ...options } : {
|
|
79
|
+
port: +options,
|
|
80
|
+
fetch: (request, server) => app.fetch(request, server)
|
|
81
|
+
};
|
|
82
|
+
if (optionsIsObject) _options.fetch = (request, server) => app.fetch(request, server);
|
|
40
83
|
const serve = _config ? {
|
|
41
84
|
..._config,
|
|
42
85
|
..._options
|
|
43
86
|
} : _options;
|
|
87
|
+
const server = app.server = Bun.serve(serve);
|
|
88
|
+
const onSetup = app["~ext"]?.setup;
|
|
89
|
+
if (onSetup) for (let i = 0; i < onSetup.length; i++) onSetup[i](app);
|
|
44
90
|
const hasWs = app["~hasWS"];
|
|
45
|
-
serve.fetch = (request, server) => app.fetch(request, server);
|
|
46
|
-
app.server = Bun.serve(serve);
|
|
47
91
|
if (!hasWs) callback?.(app.server);
|
|
48
92
|
queueMicrotask(() => {
|
|
93
|
+
if (app.server !== server) return;
|
|
49
94
|
if (!app.pending) serve.fetch = app.fetch;
|
|
50
95
|
const buildWebSocket = () => {
|
|
51
96
|
const defaultConfig = app["~config"]?.websocket;
|
|
@@ -56,15 +101,16 @@ const BunAdapter = require_adapter_index.createAdapter({
|
|
|
56
101
|
const staticRoutes = collectStaticRoutes(app);
|
|
57
102
|
if (!staticRoutes) return;
|
|
58
103
|
if (staticRoutes[1].length) return Promise.all(staticRoutes[1]).then(() => {
|
|
104
|
+
if (app.server !== server) return;
|
|
59
105
|
serve.routes = staticRoutes[0];
|
|
60
106
|
app.server.reload(serve);
|
|
61
107
|
});
|
|
62
108
|
if (Object.keys(staticRoutes[0]).length) serve.routes = staticRoutes[0];
|
|
63
109
|
};
|
|
64
110
|
if (app.pending) {
|
|
65
|
-
|
|
66
|
-
else app.server = Bun.serve(serve);
|
|
111
|
+
app.server.reload(serve);
|
|
67
112
|
const reloadAfterModules = () => {
|
|
113
|
+
if (app.server !== server) return;
|
|
68
114
|
serve.fetch = app.fetch;
|
|
69
115
|
if (hasWs || app["~hasWS"]) buildWebSocket();
|
|
70
116
|
collectRoutes();
|
|
@@ -73,8 +119,7 @@ const BunAdapter = require_adapter_index.createAdapter({
|
|
|
73
119
|
app.modules.then(reloadAfterModules, reloadAfterModules);
|
|
74
120
|
} else {
|
|
75
121
|
collectRoutes();
|
|
76
|
-
|
|
77
|
-
else app.server = Bun.serve(serve);
|
|
122
|
+
app.server.reload(serve);
|
|
78
123
|
}
|
|
79
124
|
require_memory.flushMemory();
|
|
80
125
|
if (hasWs) callback?.(app.server);
|
|
@@ -1,50 +1,95 @@
|
|
|
1
1
|
import { createAdapter } from "../index.mjs";
|
|
2
|
-
import {
|
|
2
|
+
import { isDynamicRegex, needEncodeRegex } from "../../constants.mjs";
|
|
3
|
+
import { flattenChain, getLoosePath, mapMethodBack, nullObject } from "../../utils.mjs";
|
|
3
4
|
import { WebStandardAdapter } from "../web-standard/index.mjs";
|
|
5
|
+
import { buildNativeStaticResponse } from "../../compile/handler/index.mjs";
|
|
4
6
|
import { flushMemory } from "../../memory.mjs";
|
|
5
7
|
import { buildGlobalWSHandler } from "../../ws/route.mjs";
|
|
6
8
|
|
|
7
9
|
//#region src/adapter/bun/index.ts
|
|
8
10
|
function collectStaticRoutes(app) {
|
|
9
|
-
if (app["~
|
|
10
|
-
const hook = flattenChain(app["~hookChain"]);
|
|
11
|
-
if (hook && (hook?.request?.length || hook?.mapResponse?.length || hook?.afterResponse?.length || hook?.trace?.length)) return;
|
|
11
|
+
if (app["~config"]?.nativeStaticResponse === false) return;
|
|
12
12
|
app.fetch;
|
|
13
|
-
const
|
|
14
|
-
if (
|
|
13
|
+
const fetchLevelHook = flattenChain(app["~hookChain"]);
|
|
14
|
+
if (fetchLevelHook?.request?.length || fetchLevelHook?.trace?.length || app["~ext"]?.hoc?.length) return;
|
|
15
|
+
const history = app.history;
|
|
16
|
+
if (!history?.length) return;
|
|
15
17
|
const ready = nullObject();
|
|
16
18
|
const pending = [];
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
19
|
+
const strictPath = app["~config"]?.strictPath === true;
|
|
20
|
+
const seen = /* @__PURE__ */ new Map();
|
|
21
|
+
for (let i = 0; i < history.length; i++) {
|
|
22
|
+
const route = history[i];
|
|
23
|
+
const method = route[0] === "WS" ? "WS" : mapMethodBack(route[0]);
|
|
24
|
+
seen.set(method + " " + route[1], i);
|
|
25
|
+
}
|
|
26
|
+
let explicitPaths;
|
|
27
|
+
if (!strictPath) {
|
|
28
|
+
explicitPaths = /* @__PURE__ */ new Map();
|
|
29
|
+
for (let i = 0; i < history.length; i++) {
|
|
30
|
+
const route = history[i];
|
|
31
|
+
const method = route[0] === "WS" ? "WS" : mapMethodBack(route[0]);
|
|
32
|
+
const path = route[1];
|
|
33
|
+
let set = explicitPaths.get(method);
|
|
34
|
+
if (!set) explicitPaths.set(method, set = /* @__PURE__ */ new Set());
|
|
35
|
+
set.add(path);
|
|
36
|
+
if (needEncodeRegex.test(path)) {
|
|
37
|
+
const encoded = encodeURI(path);
|
|
38
|
+
if (encoded !== path) set.add(encoded);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
const add = (method, path, value) => {
|
|
43
|
+
if (needEncodeRegex.test(path)) path = encodeURI(path);
|
|
44
|
+
if (value instanceof Promise) pending.push(value.then((resolved) => {
|
|
45
|
+
if (resolved instanceof Response) (ready[path] ??= nullObject())[method] = resolved;
|
|
46
|
+
}, (err) => {
|
|
47
|
+
console.error(`[Elysia] Static route ${method} ${path} failed to resolve:`, err);
|
|
48
|
+
}));
|
|
49
|
+
else (ready[path] ??= nullObject())[method] = value;
|
|
50
|
+
};
|
|
51
|
+
for (let i = 0; i < history.length; i++) {
|
|
52
|
+
const route = history[i];
|
|
53
|
+
if (route[0] === "WS") continue;
|
|
54
|
+
const method = mapMethodBack(route[0]);
|
|
55
|
+
const path = route[1];
|
|
56
|
+
if (seen.get(method + " " + path) !== i) continue;
|
|
57
|
+
const value = buildNativeStaticResponse(route, app);
|
|
58
|
+
if (!value) continue;
|
|
59
|
+
add(method, path, value);
|
|
60
|
+
if (!strictPath && !isDynamicRegex.test(path)) {
|
|
61
|
+
const loose = getLoosePath(path);
|
|
62
|
+
if (loose !== path && !explicitPaths?.get(method)?.has(loose)) add(method, loose, value);
|
|
28
63
|
}
|
|
29
64
|
}
|
|
65
|
+
if (!Object.keys(ready).length && !pending.length) return;
|
|
30
66
|
return [ready, pending];
|
|
31
67
|
}
|
|
32
68
|
const BunAdapter = createAdapter({
|
|
33
|
-
...WebStandardAdapter,
|
|
34
69
|
name: "bun",
|
|
35
70
|
runtime: "bun",
|
|
71
|
+
isWebStandard: true,
|
|
72
|
+
parse: WebStandardAdapter.parse,
|
|
73
|
+
response: WebStandardAdapter.response,
|
|
36
74
|
listen(app, options, callback) {
|
|
37
75
|
const _config = app["~config"]?.serve;
|
|
38
|
-
const
|
|
76
|
+
const optionsIsObject = typeof options === "object";
|
|
77
|
+
const _options = optionsIsObject ? { ...options } : {
|
|
78
|
+
port: +options,
|
|
79
|
+
fetch: (request, server) => app.fetch(request, server)
|
|
80
|
+
};
|
|
81
|
+
if (optionsIsObject) _options.fetch = (request, server) => app.fetch(request, server);
|
|
39
82
|
const serve = _config ? {
|
|
40
83
|
..._config,
|
|
41
84
|
..._options
|
|
42
85
|
} : _options;
|
|
86
|
+
const server = app.server = Bun.serve(serve);
|
|
87
|
+
const onSetup = app["~ext"]?.setup;
|
|
88
|
+
if (onSetup) for (let i = 0; i < onSetup.length; i++) onSetup[i](app);
|
|
43
89
|
const hasWs = app["~hasWS"];
|
|
44
|
-
serve.fetch = (request, server) => app.fetch(request, server);
|
|
45
|
-
app.server = Bun.serve(serve);
|
|
46
90
|
if (!hasWs) callback?.(app.server);
|
|
47
91
|
queueMicrotask(() => {
|
|
92
|
+
if (app.server !== server) return;
|
|
48
93
|
if (!app.pending) serve.fetch = app.fetch;
|
|
49
94
|
const buildWebSocket = () => {
|
|
50
95
|
const defaultConfig = app["~config"]?.websocket;
|
|
@@ -55,15 +100,16 @@ const BunAdapter = createAdapter({
|
|
|
55
100
|
const staticRoutes = collectStaticRoutes(app);
|
|
56
101
|
if (!staticRoutes) return;
|
|
57
102
|
if (staticRoutes[1].length) return Promise.all(staticRoutes[1]).then(() => {
|
|
103
|
+
if (app.server !== server) return;
|
|
58
104
|
serve.routes = staticRoutes[0];
|
|
59
105
|
app.server.reload(serve);
|
|
60
106
|
});
|
|
61
107
|
if (Object.keys(staticRoutes[0]).length) serve.routes = staticRoutes[0];
|
|
62
108
|
};
|
|
63
109
|
if (app.pending) {
|
|
64
|
-
|
|
65
|
-
else app.server = Bun.serve(serve);
|
|
110
|
+
app.server.reload(serve);
|
|
66
111
|
const reloadAfterModules = () => {
|
|
112
|
+
if (app.server !== server) return;
|
|
67
113
|
serve.fetch = app.fetch;
|
|
68
114
|
if (hasWs || app["~hasWS"]) buildWebSocket();
|
|
69
115
|
collectRoutes();
|
|
@@ -72,8 +118,7 @@ const BunAdapter = createAdapter({
|
|
|
72
118
|
app.modules.then(reloadAfterModules, reloadAfterModules);
|
|
73
119
|
} else {
|
|
74
120
|
collectRoutes();
|
|
75
|
-
|
|
76
|
-
else app.server = Bun.serve(serve);
|
|
121
|
+
app.server.reload(serve);
|
|
77
122
|
}
|
|
78
123
|
flushMemory();
|
|
79
124
|
if (hasWs) callback?.(app.server);
|
|
@@ -1,29 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
import { Context } from "../context.js";
|
|
4
|
-
import { AnyElysia } from "../base.js";
|
|
1
|
+
import { ElysiaAdapterOptions } from "./types.js";
|
|
2
|
+
|
|
5
3
|
//#region src/adapter/constants.d.ts
|
|
6
|
-
declare const defaultAdapter:
|
|
7
|
-
parse: {
|
|
8
|
-
default: (context: Context, contentType: string) => string | ArrayBuffer | unknown[] | Record<string, unknown> | Promise<unknown[] | Record<string | number | symbol, undefined>> | Promise<ArrayBuffer> | Promise<Record<string, unknown>> | Promise<string> | undefined;
|
|
9
|
-
json: (context: Context) => MaybePromise<Record<keyof any, undefined> | unknown[]>;
|
|
10
|
-
text: (context: Context) => MaybePromise<string>;
|
|
11
|
-
urlencoded: (context: Context) => MaybePromise<Record<string, string | string[]>>;
|
|
12
|
-
arrayBuffer: (context: Context) => MaybePromise<ArrayBuffer>;
|
|
13
|
-
formData: (context: Context) => MaybePromise<Record<string, unknown>>;
|
|
14
|
-
};
|
|
15
|
-
name: string;
|
|
16
|
-
runtime: "node" | "deno" | "bun" | "cloudflare-worker" | "browser" | "vercel" | "netlify" | "lambda" | "fastly" | "edge" | "unknown" | (string & {});
|
|
17
|
-
isWebStandard: boolean;
|
|
18
|
-
listen?(app: AnyElysia, options: string | number | Partial<Serve>, callback?: ListenCallback): void;
|
|
19
|
-
stop?(app: AnyElysia, closeActiveConnections?: boolean): Promise<void>;
|
|
20
|
-
response: {
|
|
21
|
-
map(response: unknown, set: Context["set"], ...params: unknown[]): unknown;
|
|
22
|
-
compact?(response: unknown, ...params: unknown[]): unknown;
|
|
23
|
-
static?(handle: unknown, hooks: AnyLocalHook, setHeaders?: Context["set"]["headers"], ...params: unknown[]): (() => unknown) | undefined;
|
|
24
|
-
nativeStatic?(handle: unknown, hooks: AnyLocalHook, set?: Context["set"]): (() => MaybePromise<Response>) | undefined;
|
|
25
|
-
};
|
|
26
|
-
fetch?(app: AnyElysia): (request: Request) => MaybePromise<Response>;
|
|
27
|
-
};
|
|
4
|
+
declare const defaultAdapter: ElysiaAdapterOptions;
|
|
28
5
|
//#endregion
|
|
29
6
|
export { defaultAdapter };
|
package/dist/adapter/index.d.ts
CHANGED
|
@@ -1,32 +1,7 @@
|
|
|
1
|
-
import { ListenCallback, Serve } from "../universal/server.js";
|
|
2
1
|
import { ElysiaAdapterOptions } from "./types.js";
|
|
3
|
-
import { AnyLocalHook, MaybePromise } from "../types.js";
|
|
4
|
-
import { Context } from "../context.js";
|
|
5
|
-
import { AnyElysia } from "../base.js";
|
|
6
2
|
|
|
7
3
|
//#region src/adapter/index.d.ts
|
|
8
|
-
declare function createAdapter(adapter: ElysiaAdapterOptions):
|
|
9
|
-
parse: {
|
|
10
|
-
default: (context: Context, contentType: string) => string | ArrayBuffer | unknown[] | Record<string, unknown> | Promise<unknown[] | Record<string | number | symbol, undefined>> | Promise<ArrayBuffer> | Promise<Record<string, unknown>> | Promise<string> | undefined;
|
|
11
|
-
json: (context: Context) => MaybePromise<Record<keyof any, undefined> | unknown[]>;
|
|
12
|
-
text: (context: Context) => MaybePromise<string>;
|
|
13
|
-
urlencoded: (context: Context) => MaybePromise<Record<string, string | string[]>>;
|
|
14
|
-
arrayBuffer: (context: Context) => MaybePromise<ArrayBuffer>;
|
|
15
|
-
formData: (context: Context) => MaybePromise<Record<string, unknown>>;
|
|
16
|
-
};
|
|
17
|
-
name: string;
|
|
18
|
-
runtime: "node" | "deno" | "bun" | "cloudflare-worker" | "browser" | "vercel" | "netlify" | "lambda" | "fastly" | "edge" | "unknown" | (string & {});
|
|
19
|
-
isWebStandard: boolean;
|
|
20
|
-
listen?(app: AnyElysia, options: string | number | Partial<Serve>, callback?: ListenCallback): void;
|
|
21
|
-
stop?(app: AnyElysia, closeActiveConnections?: boolean): Promise<void>;
|
|
22
|
-
response: {
|
|
23
|
-
map(response: unknown, set: Context["set"], ...params: unknown[]): unknown;
|
|
24
|
-
compact?(response: unknown, ...params: unknown[]): unknown;
|
|
25
|
-
static?(handle: unknown, hooks: AnyLocalHook, setHeaders?: Context["set"]["headers"], ...params: unknown[]): (() => unknown) | undefined;
|
|
26
|
-
nativeStatic?(handle: unknown, hooks: AnyLocalHook, set?: Context["set"]): (() => MaybePromise<Response>) | undefined;
|
|
27
|
-
};
|
|
28
|
-
fetch?(app: AnyElysia): (request: Request) => MaybePromise<Response>;
|
|
29
|
-
};
|
|
4
|
+
declare function createAdapter<const T extends ElysiaAdapterOptions>(adapter: ElysiaAdapterOptions): T;
|
|
30
5
|
type ElysiaAdapter = ReturnType<typeof createAdapter>;
|
|
31
6
|
//#endregion
|
|
32
7
|
export { ElysiaAdapter, type ElysiaAdapterOptions, createAdapter };
|
package/dist/adapter/index.js
CHANGED
|
@@ -2,23 +2,7 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
|
2
2
|
|
|
3
3
|
//#region src/adapter/index.ts
|
|
4
4
|
function createAdapter(adapter) {
|
|
5
|
-
return
|
|
6
|
-
...adapter,
|
|
7
|
-
parse: {
|
|
8
|
-
...adapter.parse,
|
|
9
|
-
default: ((json, urlencoded, arrayBuffer, formData, text) => (context, contentType) => {
|
|
10
|
-
switch (contentType.charCodeAt(12)) {
|
|
11
|
-
case 106: return json(context);
|
|
12
|
-
case 120:
|
|
13
|
-
if (contentType.charCodeAt(13) === 45) return urlencoded(context);
|
|
14
|
-
break;
|
|
15
|
-
case 111: return arrayBuffer(context);
|
|
16
|
-
case 114: return formData(context);
|
|
17
|
-
default: if (contentType.charCodeAt(0) === 116) return text(context);
|
|
18
|
-
}
|
|
19
|
-
})(adapter.parse.json, adapter.parse.urlencoded, adapter.parse.arrayBuffer, adapter.parse.formData, adapter.parse.text)
|
|
20
|
-
}
|
|
21
|
-
};
|
|
5
|
+
return adapter;
|
|
22
6
|
}
|
|
23
7
|
|
|
24
8
|
//#endregion
|
package/dist/adapter/index.mjs
CHANGED
|
@@ -1,22 +1,6 @@
|
|
|
1
1
|
//#region src/adapter/index.ts
|
|
2
2
|
function createAdapter(adapter) {
|
|
3
|
-
return
|
|
4
|
-
...adapter,
|
|
5
|
-
parse: {
|
|
6
|
-
...adapter.parse,
|
|
7
|
-
default: ((json, urlencoded, arrayBuffer, formData, text) => (context, contentType) => {
|
|
8
|
-
switch (contentType.charCodeAt(12)) {
|
|
9
|
-
case 106: return json(context);
|
|
10
|
-
case 120:
|
|
11
|
-
if (contentType.charCodeAt(13) === 45) return urlencoded(context);
|
|
12
|
-
break;
|
|
13
|
-
case 111: return arrayBuffer(context);
|
|
14
|
-
case 114: return formData(context);
|
|
15
|
-
default: if (contentType.charCodeAt(0) === 116) return text(context);
|
|
16
|
-
}
|
|
17
|
-
})(adapter.parse.json, adapter.parse.urlencoded, adapter.parse.arrayBuffer, adapter.parse.formData, adapter.parse.text)
|
|
18
|
-
}
|
|
19
|
-
};
|
|
3
|
+
return adapter;
|
|
20
4
|
}
|
|
21
5
|
|
|
22
6
|
//#endregion
|
package/dist/adapter/types.d.ts
CHANGED
|
@@ -23,6 +23,12 @@ interface ElysiaAdapterOptions {
|
|
|
23
23
|
* Whether this adapter is web standard
|
|
24
24
|
*/
|
|
25
25
|
isWebStandard: boolean;
|
|
26
|
+
/**
|
|
27
|
+
* Whether this adapter supports WebSocket.
|
|
28
|
+
*
|
|
29
|
+
* `.ws()` throws on non-Bun runtimes unless this is set.
|
|
30
|
+
*/
|
|
31
|
+
websocket?: boolean;
|
|
26
32
|
listen?(app: AnyElysia, options: string | number | Partial<Serve>, callback?: ListenCallback): void;
|
|
27
33
|
/**
|
|
28
34
|
* Stop server from serving
|
|
@@ -45,6 +51,7 @@ interface ElysiaAdapterOptions {
|
|
|
45
51
|
urlencoded: (context: Context) => MaybePromise<Record<string, string | string[]>>;
|
|
46
52
|
arrayBuffer: (context: Context) => MaybePromise<ArrayBuffer>;
|
|
47
53
|
formData: (context: Context) => MaybePromise<Record<string, unknown>>;
|
|
54
|
+
default: (context: Context, contentType: string) => MaybePromise<any>;
|
|
48
55
|
};
|
|
49
56
|
response: {
|
|
50
57
|
/**
|
package/dist/adapter/utils.d.ts
CHANGED
|
@@ -2,9 +2,9 @@ import { StatusMap } from "../constants.js";
|
|
|
2
2
|
import { BaseCookie } from "../cookie/types.js";
|
|
3
3
|
import { HTTPHeaders } from "../types.js";
|
|
4
4
|
import { Context } from "../context.js";
|
|
5
|
-
|
|
6
5
|
//#region src/adapter/utils.d.ts
|
|
7
6
|
declare function handleFile(response: File | Blob, set?: Context['set'], request?: Request): Response;
|
|
7
|
+
declare function normalizeHeaders(set: Context['set']): void;
|
|
8
8
|
declare function parseSetCookies(headers: Headers, setCookie: string[]): Headers;
|
|
9
9
|
declare function responseToSetHeaders(response: Response, set?: Context['set']): {
|
|
10
10
|
headers: HTTPHeaders;
|
|
@@ -12,21 +12,21 @@ declare function responseToSetHeaders(response: Response, set?: Context['set']):
|
|
|
12
12
|
cookie?: Record<string, BaseCookie>;
|
|
13
13
|
} | {
|
|
14
14
|
headers: any;
|
|
15
|
-
status: number | "
|
|
15
|
+
status: number | "Continue" | "Switching Protocols" | "Processing" | "Early Hints" | "OK" | "Created" | "Accepted" | "Non-Authoritative Information" | "No Content" | "Reset Content" | "Partial Content" | "Multi-Status" | "Already Reported" | "Multiple Choices" | "Moved Permanently" | "Found" | "See Other" | "Not Modified" | "Temporary Redirect" | "Permanent Redirect" | "Bad Request" | "Unauthorized" | "Payment Required" | "Forbidden" | "Not Found" | "Method Not Allowed" | "Not Acceptable" | "Proxy Authentication Required" | "Request Timeout" | "Conflict" | "Gone" | "Length Required" | "Precondition Failed" | "Payload Too Large" | "URI Too Long" | "Unsupported Media Type" | "Range Not Satisfiable" | "Expectation Failed" | "I'm a teapot" | "Enhance Your Calm" | "Misdirected Request" | "Unprocessable Content" | "Locked" | "Failed Dependency" | "Too Early" | "Upgrade Required" | "Precondition Required" | "Too Many Requests" | "Request Header Fields Too Large" | "Unavailable For Legal Reasons" | "Internal Server Error" | "Not Implemented" | "Bad Gateway" | "Service Unavailable" | "Gateway Timeout" | "HTTP Version Not Supported" | "Variant Also Negotiates" | "Insufficient Storage" | "Loop Detected" | "Not Extended" | "Network Authentication Required";
|
|
16
16
|
};
|
|
17
17
|
interface CreateHandlerParameter {
|
|
18
18
|
mapResponse(response: unknown, set: Context['set'], request?: Request): Response;
|
|
19
19
|
mapCompactResponse(response: unknown, request?: Request): Response;
|
|
20
20
|
}
|
|
21
|
-
declare
|
|
21
|
+
declare function createStreamHandler({
|
|
22
22
|
mapResponse,
|
|
23
23
|
mapCompactResponse
|
|
24
|
-
}: CreateHandlerParameter)
|
|
24
|
+
}: CreateHandlerParameter): (generator: Generator | AsyncGenerator | ReadableStream, set?: Context["set"], request?: Request, skipFormat?: boolean) => Promise<Response>;
|
|
25
25
|
declare function streamResponse(response: Response): AsyncGenerator<any, void, any>;
|
|
26
26
|
declare function handleSet(set: Context['set']): void;
|
|
27
27
|
declare function mergeHeaders(responseHeaders: Headers, setHeaders: Context['set']['headers']): Headers;
|
|
28
28
|
declare function mergeStatus(responseStatus: number, setStatus: Context['set']['status']): number | undefined;
|
|
29
|
-
declare
|
|
29
|
+
declare function createResponseHandler(handler: CreateHandlerParameter): (response: Response, set?: Context["set"], request?: Request) => any;
|
|
30
30
|
/**
|
|
31
31
|
* Split async source into `branches` independent iterators
|
|
32
32
|
*
|
|
@@ -34,15 +34,17 @@ declare const createResponseHandler: (handler: CreateHandlerParameter) => (respo
|
|
|
34
34
|
*
|
|
35
35
|
* To prevent long/infinite stream, the unconsumed window is capped:
|
|
36
36
|
* Consumed-by-every-branch entries are trimmed off the front
|
|
37
|
-
* Producer backpressures whenever the window hits `cap`
|
|
38
|
-
*
|
|
39
|
-
*
|
|
37
|
+
* Producer backpressures whenever the window hits `cap` ENTRIES or
|
|
38
|
+
* `capBytes` bytes, whichever comes first
|
|
39
|
+
*
|
|
40
|
+
* Streams below both caps buffer eagerly
|
|
41
|
+
* Only streams exceeding one gate on the slowest consumer
|
|
40
42
|
*
|
|
41
43
|
* Branch 0 is the value consumer (response/client)
|
|
42
|
-
* When
|
|
44
|
+
* When `return()` (client abort / early exit), source is stopped
|
|
43
45
|
* so the observer branches can still reach completion instead of spinning
|
|
44
|
-
* an infinite source
|
|
46
|
+
* an infinite source
|
|
45
47
|
*/
|
|
46
|
-
declare function tee<T>(source: AsyncIterable<T>, branches?: number, cap?: number):
|
|
48
|
+
declare function tee<T>(source: AsyncIterable<T>, branches?: number, cap?: number, capBytes?: number): AsyncIterableIterator<T>[];
|
|
47
49
|
//#endregion
|
|
48
|
-
export { createResponseHandler, createStreamHandler, handleFile, handleSet, mergeHeaders, mergeStatus, parseSetCookies, responseToSetHeaders, streamResponse, tee };
|
|
50
|
+
export { createResponseHandler, createStreamHandler, handleFile, handleSet, mergeHeaders, mergeStatus, normalizeHeaders, parseSetCookies, responseToSetHeaders, streamResponse, tee };
|