elysia 2.0.0-exp.4 → 2.0.0-exp.5
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/adapter/utils.d.ts +2 -5
- package/dist/adapter/utils.js +8 -7
- package/dist/adapter/utils.mjs +5 -4
- package/dist/adapter/web-standard/handler.js +1 -1
- package/dist/adapter/web-standard/handler.mjs +1 -1
- package/dist/base.js +2 -2
- package/dist/base.mjs +2 -2
- package/dist/compile/handler/jit.js +3 -3
- package/dist/compile/handler/jit.mjs +3 -3
- package/dist/compile/handler/params.js +2 -2
- package/dist/compile/handler/params.mjs +2 -2
- package/dist/compile/handler/reconstruct.js +1 -1
- package/dist/compile/handler/reconstruct.mjs +1 -1
- package/dist/compile/handler/utils.js +3 -3
- package/dist/compile/handler/utils.mjs +3 -3
- package/dist/cookie/index.d.ts +2 -1
- package/dist/cookie/index.js +2 -1
- package/dist/cookie/index.mjs +2 -1
- package/dist/cookie/serialize.d.ts +6 -0
- package/dist/cookie/serialize.js +28 -0
- package/dist/cookie/serialize.mjs +27 -0
- package/dist/cookie/utils.d.ts +1 -2
- package/dist/cookie/utils.js +1 -22
- package/dist/cookie/utils.mjs +4 -24
- package/dist/error.d.ts +1 -1
- package/dist/handler/fetch.js +1 -1
- package/dist/handler/fetch.mjs +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +3 -3
- package/dist/index.mjs +2 -2
- package/dist/plugin/core.d.ts +6 -5
- package/dist/plugin/core.js +11 -7
- package/dist/plugin/core.mjs +11 -7
- package/dist/plugin/vite.js +2 -1
- package/dist/plugin/vite.mjs +2 -1
- package/dist/type/bridge.d.ts +7 -7
- package/dist/type/coerce.d.ts +1 -1
- package/dist/type/constants.d.ts +1 -1
- package/dist/type/elysia/file-type.js +1 -1
- package/dist/type/elysia/file-type.mjs +1 -1
- package/dist/type/types.d.ts +1 -1
- package/dist/type/validator/default-precompute.d.ts +5 -2
- package/dist/type/validator/default-precompute.js +148 -8
- package/dist/type/validator/default-precompute.mjs +147 -9
- package/dist/type/validator/index.d.ts +1 -1
- package/dist/type/validator/index.js +18 -14
- package/dist/type/validator/index.mjs +19 -15
- package/dist/types.d.ts +1 -1
- package/dist/universal/file.js +5 -4
- package/dist/universal/file.mjs +5 -4
- package/dist/validator/index.js +2 -2
- package/dist/validator/index.mjs +2 -2
- package/package.json +2 -1
package/dist/adapter/utils.d.ts
CHANGED
|
@@ -12,16 +12,13 @@ declare function responseToSetHeaders(response: Response, set?: Context['set']):
|
|
|
12
12
|
cookie?: Record<string, BaseCookie>;
|
|
13
13
|
} | {
|
|
14
14
|
headers: any;
|
|
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" | "
|
|
15
|
+
status: number | "Bad Request" | "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" | "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 const createStreamHandler: (
|
|
22
|
-
mapResponse,
|
|
23
|
-
mapCompactResponse
|
|
24
|
-
}: CreateHandlerParameter) => (generator: Generator | AsyncGenerator | ReadableStream, set?: Context["set"], request?: Request, skipFormat?: boolean) => Promise<Response>;
|
|
21
|
+
declare const createStreamHandler: (_: CreateHandlerParameter) => (generator: Generator | AsyncGenerator | ReadableStream, set?: Context["set"], request?: Request, skipFormat?: boolean) => Promise<Response>;
|
|
25
22
|
declare function streamResponse(response: Response): AsyncGenerator<any, void, any>;
|
|
26
23
|
declare function handleSet(set: Context['set']): void;
|
|
27
24
|
declare function mergeHeaders(responseHeaders: Headers, setHeaders: Context['set']['headers']): Headers;
|
package/dist/adapter/utils.js
CHANGED
|
@@ -2,7 +2,8 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
|
2
2
|
const require_universal_constants = require('../universal/constants.js');
|
|
3
3
|
const require_constants = require('../constants.js');
|
|
4
4
|
const require_utils = require('../utils.js');
|
|
5
|
-
const
|
|
5
|
+
const require_cookie_serialize = require('../cookie/serialize.js');
|
|
6
|
+
const require_adapter_web_standard_handler = require('./web-standard/handler.js');
|
|
6
7
|
|
|
7
8
|
//#region src/adapter/utils.ts
|
|
8
9
|
const setCookie = "set-cookie";
|
|
@@ -101,7 +102,7 @@ function responseToSetHeaders(response, set) {
|
|
|
101
102
|
} else if (set.headers["content-encoding"]) delete set.headers["content-encoding"];
|
|
102
103
|
return set;
|
|
103
104
|
}
|
|
104
|
-
|
|
105
|
+
function enqueueBinaryChunk(controller, chunk) {
|
|
105
106
|
if (chunk instanceof Blob) return chunk.arrayBuffer().then((buffer) => {
|
|
106
107
|
controller.enqueue(new Uint8Array(buffer));
|
|
107
108
|
return true;
|
|
@@ -119,15 +120,15 @@ const enqueueBinaryChunk = (controller, chunk) => {
|
|
|
119
120
|
return true;
|
|
120
121
|
}
|
|
121
122
|
return false;
|
|
122
|
-
}
|
|
123
|
-
const createStreamHandler = (
|
|
123
|
+
}
|
|
124
|
+
const createStreamHandler = (_) => async (generator, set, request, skipFormat) => {
|
|
124
125
|
let init = generator.next?.();
|
|
125
126
|
if (set) handleSet(set);
|
|
126
127
|
if (init instanceof Promise) init = await init;
|
|
127
128
|
if (init?.value instanceof ReadableStream) generator = init.value;
|
|
128
129
|
else if (init && (typeof init?.done === "undefined" || init?.done)) {
|
|
129
|
-
if (set) return mapResponse(init.value, set, request);
|
|
130
|
-
return mapCompactResponse(init.value, request);
|
|
130
|
+
if (set) return require_adapter_web_standard_handler.mapResponse(init.value, set, request);
|
|
131
|
+
return require_adapter_web_standard_handler.mapCompactResponse(init.value, request);
|
|
131
132
|
}
|
|
132
133
|
const isSSE = !skipFormat && (init?.value?.sse ?? generator?.sse ?? set?.headers["content-type"]?.startsWith("text/event-stream"));
|
|
133
134
|
const format = isSSE ? (data) => `data: ${data}\n\n` : (data) => data;
|
|
@@ -217,7 +218,7 @@ function handleSet(set) {
|
|
|
217
218
|
set.headers = flat;
|
|
218
219
|
}
|
|
219
220
|
if (set.cookie && require_utils.isNotEmpty(set.cookie)) {
|
|
220
|
-
const cookie =
|
|
221
|
+
const cookie = require_cookie_serialize.serializeCookie(set.cookie);
|
|
221
222
|
if (cookie) set.headers[setCookie] = cookie;
|
|
222
223
|
}
|
|
223
224
|
if (set.headers[setCookie] && Array.isArray(set.headers[setCookie])) set.headers = parseSetCookies(new Headers(set.headers), set.headers[setCookie]);
|
package/dist/adapter/utils.mjs
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { hasHeaderShorthand, isBun } from "../universal/constants.mjs";
|
|
2
2
|
import { StatusMap } from "../constants.mjs";
|
|
3
3
|
import { isNotEmpty, nullObject } from "../utils.mjs";
|
|
4
|
-
import { serializeCookie } from "../cookie/
|
|
4
|
+
import { serializeCookie } from "../cookie/serialize.mjs";
|
|
5
|
+
import { mapCompactResponse, mapResponse } from "./web-standard/handler.mjs";
|
|
5
6
|
|
|
6
7
|
//#region src/adapter/utils.ts
|
|
7
8
|
const setCookie = "set-cookie";
|
|
@@ -100,7 +101,7 @@ function responseToSetHeaders(response, set) {
|
|
|
100
101
|
} else if (set.headers["content-encoding"]) delete set.headers["content-encoding"];
|
|
101
102
|
return set;
|
|
102
103
|
}
|
|
103
|
-
|
|
104
|
+
function enqueueBinaryChunk(controller, chunk) {
|
|
104
105
|
if (chunk instanceof Blob) return chunk.arrayBuffer().then((buffer) => {
|
|
105
106
|
controller.enqueue(new Uint8Array(buffer));
|
|
106
107
|
return true;
|
|
@@ -118,8 +119,8 @@ const enqueueBinaryChunk = (controller, chunk) => {
|
|
|
118
119
|
return true;
|
|
119
120
|
}
|
|
120
121
|
return false;
|
|
121
|
-
}
|
|
122
|
-
const createStreamHandler = (
|
|
122
|
+
}
|
|
123
|
+
const createStreamHandler = (_) => async (generator, set, request, skipFormat) => {
|
|
123
124
|
let init = generator.next?.();
|
|
124
125
|
if (set) handleSet(set);
|
|
125
126
|
if (init instanceof Promise) init = await init;
|
|
@@ -2,8 +2,8 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
|
2
2
|
const require_universal_constants = require('../../universal/constants.js');
|
|
3
3
|
const require_universal_file = require('../../universal/file.js');
|
|
4
4
|
const require_utils = require('../../utils.js');
|
|
5
|
-
const require_error = require('../../error.js');
|
|
6
5
|
const require_adapter_utils = require('../utils.js');
|
|
6
|
+
const require_error = require('../../error.js');
|
|
7
7
|
|
|
8
8
|
//#region src/adapter/web-standard/handler.ts
|
|
9
9
|
function handleElysiaFile(file, set = { headers: require_utils.nullObject() }, request) {
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { isBun } from "../../universal/constants.mjs";
|
|
2
2
|
import { mime } from "../../universal/file.mjs";
|
|
3
3
|
import { formToFormData, isNotEmpty, nullObject } from "../../utils.mjs";
|
|
4
|
-
import { ElysiaStatus, isProduction } from "../../error.mjs";
|
|
5
4
|
import { createResponseHandler, createStreamHandler, handleFile, handleSet } from "../utils.mjs";
|
|
5
|
+
import { ElysiaStatus, isProduction } from "../../error.mjs";
|
|
6
6
|
|
|
7
7
|
//#region src/adapter/web-standard/handler.ts
|
|
8
8
|
function handleElysiaFile(file, set = { headers: nullObject() }, request) {
|
package/dist/base.js
CHANGED
|
@@ -378,7 +378,7 @@ var Elysia = class Elysia {
|
|
|
378
378
|
return this;
|
|
379
379
|
}
|
|
380
380
|
macro(macro) {
|
|
381
|
-
if (typeof macro === "function") throw new Error("
|
|
381
|
+
if (typeof macro === "function") throw new Error("use `.macro({ name: fn })` instead of `.macro(fn)`");
|
|
382
382
|
const ext = this.#ext;
|
|
383
383
|
const m = ext.macro ??= require_utils.nullObject();
|
|
384
384
|
for (const key in macro) if (typeof macro[key] === "object") macro[key] = require_utils.hookToGuard(macro[key]);
|
|
@@ -1030,7 +1030,7 @@ var Elysia = class Elysia {
|
|
|
1030
1030
|
return this;
|
|
1031
1031
|
}
|
|
1032
1032
|
wrap(callback) {
|
|
1033
|
-
if (this.#fetchFn) console.warn("[Elysia] .wrap() was called after the fetch handler was built
|
|
1033
|
+
if (this.#fetchFn) console.warn("[Elysia] .wrap() was called after the fetch handler was built");
|
|
1034
1034
|
const ext = this.#ext;
|
|
1035
1035
|
(ext.hoc ??= []).push(callback);
|
|
1036
1036
|
return this;
|
package/dist/base.mjs
CHANGED
|
@@ -375,7 +375,7 @@ var Elysia = class Elysia {
|
|
|
375
375
|
return this;
|
|
376
376
|
}
|
|
377
377
|
macro(macro) {
|
|
378
|
-
if (typeof macro === "function") throw new Error("
|
|
378
|
+
if (typeof macro === "function") throw new Error("use `.macro({ name: fn })` instead of `.macro(fn)`");
|
|
379
379
|
const ext = this.#ext;
|
|
380
380
|
const m = ext.macro ??= nullObject();
|
|
381
381
|
for (const key in macro) if (typeof macro[key] === "object") macro[key] = hookToGuard(macro[key]);
|
|
@@ -1027,7 +1027,7 @@ var Elysia = class Elysia {
|
|
|
1027
1027
|
return this;
|
|
1028
1028
|
}
|
|
1029
1029
|
wrap(callback) {
|
|
1030
|
-
if (this.#fetchFn) console.warn("[Elysia] .wrap() was called after the fetch handler was built
|
|
1030
|
+
if (this.#fetchFn) console.warn("[Elysia] .wrap() was called after the fetch handler was built");
|
|
1031
1031
|
const ext = this.#ext;
|
|
1032
1032
|
(ext.hoc ??= []).push(callback);
|
|
1033
1033
|
return this;
|
|
@@ -2,10 +2,8 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
|
2
2
|
const require_universal_constants = require('../../universal/constants.js');
|
|
3
3
|
const require_constants = require('../../constants.js');
|
|
4
4
|
const require_utils = require('../../utils.js');
|
|
5
|
-
const require_error = require('../../error.js');
|
|
6
|
-
const require_cookie_config = require('../../cookie/config.js');
|
|
7
|
-
const require_cookie_utils = require('../../cookie/utils.js');
|
|
8
5
|
const require_adapter_utils = require('../../adapter/utils.js');
|
|
6
|
+
const require_error = require('../../error.js');
|
|
9
7
|
const require_parse_query = require('../../parse-query.js');
|
|
10
8
|
const require_sucrose = require('../../sucrose.js');
|
|
11
9
|
const require_compile_aot = require('../aot.js');
|
|
@@ -13,6 +11,8 @@ const require_compile_utils = require('../utils.js');
|
|
|
13
11
|
const require_compile_handler_utils = require('./utils.js');
|
|
14
12
|
const require_handler_utils = require('../../handler/utils.js');
|
|
15
13
|
const require_trace = require('../../trace.js');
|
|
14
|
+
const require_cookie_config = require('../../cookie/config.js');
|
|
15
|
+
const require_cookie_utils = require('../../cookie/utils.js');
|
|
16
16
|
const require_compile_jit_probe = require('../jit-probe.js');
|
|
17
17
|
|
|
18
18
|
//#region src/compile/handler/jit.ts
|
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
import { hasHeaderShorthand } from "../../universal/constants.mjs";
|
|
2
2
|
import { isDynamicRegex } from "../../constants.mjs";
|
|
3
3
|
import { requestId } from "../../utils.mjs";
|
|
4
|
-
import { ElysiaStatus, ParseError, ValidationError } from "../../error.mjs";
|
|
5
|
-
import { compileCookieConfig } from "../../cookie/config.mjs";
|
|
6
|
-
import { buildCookieJar, parseCookieRaw, parseCookieRawSync, signCookieValues } from "../../cookie/utils.mjs";
|
|
7
4
|
import { tee } from "../../adapter/utils.mjs";
|
|
5
|
+
import { ElysiaStatus, ParseError, ValidationError } from "../../error.mjs";
|
|
8
6
|
import { parseQueryFromURL } from "../../parse-query.mjs";
|
|
9
7
|
import { sucrose } from "../../sucrose.mjs";
|
|
10
8
|
import { Capture } from "../aot.mjs";
|
|
@@ -12,6 +10,8 @@ import { isAsyncFunction, isAsyncLifecycle, mayReturnPromise } from "../utils.mj
|
|
|
12
10
|
import { cloneResponse, getQueryParseArgs, hasRequestBody, mapAfterHandle, mapAfterResponse, mapBeforeHandle, mapError, mapMapResponse, mapTransform } from "./utils.mjs";
|
|
13
11
|
import { forwardError } from "../../handler/utils.mjs";
|
|
14
12
|
import { createTracer } from "../../trace.mjs";
|
|
13
|
+
import { compileCookieConfig } from "../../cookie/config.mjs";
|
|
14
|
+
import { buildCookieJar, parseCookieRaw, parseCookieRawSync, signCookieValues } from "../../cookie/utils.mjs";
|
|
15
15
|
import { JITProbe } from "../jit-probe.mjs";
|
|
16
16
|
|
|
17
17
|
//#region src/compile/handler/jit.ts
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
2
|
const require_utils = require('../../utils.js');
|
|
3
|
-
const require_error = require('../../error.js');
|
|
4
|
-
const require_cookie_utils = require('../../cookie/utils.js');
|
|
5
3
|
const require_adapter_utils = require('../../adapter/utils.js');
|
|
4
|
+
const require_error = require('../../error.js');
|
|
6
5
|
const require_parse_query = require('../../parse-query.js');
|
|
7
6
|
const require_compile_handler_utils = require('./utils.js');
|
|
8
7
|
const require_handler_utils = require('../../handler/utils.js');
|
|
8
|
+
const require_cookie_utils = require('../../cookie/utils.js');
|
|
9
9
|
|
|
10
10
|
//#region src/compile/handler/params.ts
|
|
11
11
|
const HANDLER_PARAMS = {
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { requestId } from "../../utils.mjs";
|
|
2
|
-
import { ElysiaStatus, ParseError, ValidationError } from "../../error.mjs";
|
|
3
|
-
import { buildCookieJar, parseCookieRaw, parseCookieRawSync, signCookieValues } from "../../cookie/utils.mjs";
|
|
4
2
|
import { tee } from "../../adapter/utils.mjs";
|
|
3
|
+
import { ElysiaStatus, ParseError, ValidationError } from "../../error.mjs";
|
|
5
4
|
import { parseQueryFromURL } from "../../parse-query.mjs";
|
|
6
5
|
import { cloneResponse, hasRequestBody } from "./utils.mjs";
|
|
7
6
|
import { forwardError } from "../../handler/utils.mjs";
|
|
7
|
+
import { buildCookieJar, parseCookieRaw, parseCookieRawSync, signCookieValues } from "../../cookie/utils.mjs";
|
|
8
8
|
|
|
9
9
|
//#region src/compile/handler/params.ts
|
|
10
10
|
const HANDLER_PARAMS = {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
-
const require_cookie_config = require('../../cookie/config.js');
|
|
3
2
|
const require_validator_route = require('../../validator/route.js');
|
|
4
3
|
const require_trace = require('../../trace.js');
|
|
4
|
+
const require_cookie_config = require('../../cookie/config.js');
|
|
5
5
|
|
|
6
6
|
//#region src/compile/handler/reconstruct.ts
|
|
7
7
|
var Reconstrct = class {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { compileCookieConfig } from "../../cookie/config.mjs";
|
|
2
1
|
import { RouteValidator } from "../../validator/route.mjs";
|
|
3
2
|
import { createTracer } from "../../trace.mjs";
|
|
3
|
+
import { compileCookieConfig } from "../../cookie/config.mjs";
|
|
4
4
|
|
|
5
5
|
//#region src/compile/handler/reconstruct.ts
|
|
6
6
|
var Reconstrct = class {
|
|
@@ -17,7 +17,7 @@ function hasRequestBody(request) {
|
|
|
17
17
|
}
|
|
18
18
|
const trace = (report, fn) => report?.resolveChild(childName(fn)) ?? noTrace;
|
|
19
19
|
const toArray = (v) => Array.isArray(v) ? v : [v];
|
|
20
|
-
const mapTransform = map((i, fn, [report]) => {
|
|
20
|
+
const mapTransform = /* @__PURE__ */ map((i, fn, [report]) => {
|
|
21
21
|
const t = trace(report, fn);
|
|
22
22
|
return t.begin + `${Await(fn)}tf${at(i)}(c)\n` + t.end();
|
|
23
23
|
});
|
|
@@ -340,11 +340,11 @@ function mapAfterHandle(_hooks, report) {
|
|
|
340
340
|
return mapChainHook(toArray(_hooks), "af", report);
|
|
341
341
|
}
|
|
342
342
|
const mapMapResponse = (_hooks, report) => mapChainHook(toArray(_hooks), "mr", report);
|
|
343
|
-
const mapAfterResponse = map((i, fn, [report]) => {
|
|
343
|
+
const mapAfterResponse = /* @__PURE__ */ map((i, fn, [report]) => {
|
|
344
344
|
const t = trace(report, fn);
|
|
345
345
|
return `try{` + t.begin + `${Await(fn)}ar${at(i)}(c)\n` + t.end() + `}catch(_e){` + t.end("_e") + `}\n`;
|
|
346
346
|
});
|
|
347
|
-
const mapError = map((i, fn, [map, link, mapResponse, schedule, sign]) => {
|
|
347
|
+
const mapError = /* @__PURE__ */ map((i, fn, [map, link, mapResponse, schedule, sign]) => {
|
|
348
348
|
link(mapResponse, "rm");
|
|
349
349
|
return `_r=${Await(fn)}er${at(i)}(c)\nif(_r!==undefined){\nif(_r instanceof Response)c.set.status=_r.status\nelse if(c.set.status===undefined||c.set.status===200)c.set.status=500\n` + schedule + sign + `return ${map}(_r,c.set,c.request)\n}\n`;
|
|
350
350
|
});
|
|
@@ -16,7 +16,7 @@ function hasRequestBody(request) {
|
|
|
16
16
|
}
|
|
17
17
|
const trace = (report, fn) => report?.resolveChild(childName(fn)) ?? noTrace;
|
|
18
18
|
const toArray = (v) => Array.isArray(v) ? v : [v];
|
|
19
|
-
const mapTransform = map((i, fn, [report]) => {
|
|
19
|
+
const mapTransform = /* @__PURE__ */ map((i, fn, [report]) => {
|
|
20
20
|
const t = trace(report, fn);
|
|
21
21
|
return t.begin + `${Await(fn)}tf${at(i)}(c)\n` + t.end();
|
|
22
22
|
});
|
|
@@ -339,11 +339,11 @@ function mapAfterHandle(_hooks, report) {
|
|
|
339
339
|
return mapChainHook(toArray(_hooks), "af", report);
|
|
340
340
|
}
|
|
341
341
|
const mapMapResponse = (_hooks, report) => mapChainHook(toArray(_hooks), "mr", report);
|
|
342
|
-
const mapAfterResponse = map((i, fn, [report]) => {
|
|
342
|
+
const mapAfterResponse = /* @__PURE__ */ map((i, fn, [report]) => {
|
|
343
343
|
const t = trace(report, fn);
|
|
344
344
|
return `try{` + t.begin + `${Await(fn)}ar${at(i)}(c)\n` + t.end() + `}catch(_e){` + t.end("_e") + `}\n`;
|
|
345
345
|
});
|
|
346
|
-
const mapError = map((i, fn, [map, link, mapResponse, schedule, sign]) => {
|
|
346
|
+
const mapError = /* @__PURE__ */ map((i, fn, [map, link, mapResponse, schedule, sign]) => {
|
|
347
347
|
link(mapResponse, "rm");
|
|
348
348
|
return `_r=${Await(fn)}er${at(i)}(c)\nif(_r!==undefined){\nif(_r instanceof Response)c.set.status=_r.status\nelse if(c.set.status===undefined||c.set.status===200)c.set.status=500\n` + schedule + sign + `return ${map}(_r,c.set,c.request)\n}\n`;
|
|
349
349
|
});
|
package/dist/cookie/index.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { CookieOptions } from "./types.js";
|
|
2
2
|
import { Cookie } from "./cookie.js";
|
|
3
|
-
import {
|
|
3
|
+
import { serializeCookie } from "./serialize.js";
|
|
4
|
+
import { createCookieJar, parseCookie, signCookie, unsignCookie } from "./utils.js";
|
|
4
5
|
export { Cookie, type CookieOptions, createCookieJar, parseCookie, serializeCookie, signCookie, unsignCookie };
|
package/dist/cookie/index.js
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
+
const require_cookie_serialize = require('./serialize.js');
|
|
2
3
|
const require_cookie_cookie = require('./cookie.js');
|
|
3
4
|
const require_cookie_utils = require('./utils.js');
|
|
4
5
|
|
|
5
6
|
exports.Cookie = require_cookie_cookie.Cookie;
|
|
6
7
|
exports.createCookieJar = require_cookie_utils.createCookieJar;
|
|
7
8
|
exports.parseCookie = require_cookie_utils.parseCookie;
|
|
8
|
-
exports.serializeCookie =
|
|
9
|
+
exports.serializeCookie = require_cookie_serialize.serializeCookie;
|
|
9
10
|
exports.signCookie = require_cookie_utils.signCookie;
|
|
10
11
|
exports.unsignCookie = require_cookie_utils.unsignCookie;
|
package/dist/cookie/index.mjs
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
+
import { serializeCookie } from "./serialize.mjs";
|
|
1
2
|
import { Cookie } from "./cookie.mjs";
|
|
2
|
-
import { createCookieJar, parseCookie,
|
|
3
|
+
import { createCookieJar, parseCookie, signCookie, unsignCookie } from "./utils.mjs";
|
|
3
4
|
|
|
4
5
|
export { Cookie, createCookieJar, parseCookie, serializeCookie, signCookie, unsignCookie };
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
+
const require_utils = require('../utils.js');
|
|
3
|
+
const require_cookie_lib = require('./lib.js');
|
|
4
|
+
|
|
5
|
+
//#region src/cookie/serialize.ts
|
|
6
|
+
function serializeCookie(cookies) {
|
|
7
|
+
if (!cookies || !require_utils.isNotEmpty(cookies)) return;
|
|
8
|
+
let set;
|
|
9
|
+
let isArray = false;
|
|
10
|
+
for (const key in cookies) {
|
|
11
|
+
if (!key) continue;
|
|
12
|
+
const property = cookies[key];
|
|
13
|
+
if (!property) continue;
|
|
14
|
+
const value = property.value;
|
|
15
|
+
if (value === void 0 || value === null) continue;
|
|
16
|
+
const v = require_cookie_lib.serialize(key, value, property);
|
|
17
|
+
if (set) if (isArray) set.push(v);
|
|
18
|
+
else {
|
|
19
|
+
set = [set, v];
|
|
20
|
+
isArray = true;
|
|
21
|
+
}
|
|
22
|
+
else set = v;
|
|
23
|
+
}
|
|
24
|
+
return set;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
//#endregion
|
|
28
|
+
exports.serializeCookie = serializeCookie;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { isNotEmpty } from "../utils.mjs";
|
|
2
|
+
import { serialize } from "./lib.mjs";
|
|
3
|
+
|
|
4
|
+
//#region src/cookie/serialize.ts
|
|
5
|
+
function serializeCookie(cookies) {
|
|
6
|
+
if (!cookies || !isNotEmpty(cookies)) return;
|
|
7
|
+
let set;
|
|
8
|
+
let isArray = false;
|
|
9
|
+
for (const key in cookies) {
|
|
10
|
+
if (!key) continue;
|
|
11
|
+
const property = cookies[key];
|
|
12
|
+
if (!property) continue;
|
|
13
|
+
const value = property.value;
|
|
14
|
+
if (value === void 0 || value === null) continue;
|
|
15
|
+
const v = serialize(key, value, property);
|
|
16
|
+
if (set) if (isArray) set.push(v);
|
|
17
|
+
else {
|
|
18
|
+
set = [set, v];
|
|
19
|
+
isArray = true;
|
|
20
|
+
}
|
|
21
|
+
else set = v;
|
|
22
|
+
}
|
|
23
|
+
return set;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
//#endregion
|
|
27
|
+
export { serializeCookie };
|
package/dist/cookie/utils.d.ts
CHANGED
|
@@ -12,8 +12,7 @@ declare function parseCookieRawSync(cookieString: string | null | undefined, _co
|
|
|
12
12
|
declare function parseCookieRaw(cookieString: string | null | undefined, config: CompiledCookieConfig): Promise<Record<string, unknown>>;
|
|
13
13
|
declare function buildCookieJar(set: Context['set'], raw: Record<string, unknown>, config: CompiledCookieConfig): Record<string, Cookie<unknown>>;
|
|
14
14
|
declare function signCookieValues(cookies: Context['set']['cookie'] | undefined, config: CompiledCookieConfig): Promise<void> | undefined;
|
|
15
|
-
declare function serializeCookie(cookies: Context['set']['cookie']): string | string[] | undefined;
|
|
16
15
|
declare function signCookie(val: string, secret: string | null): Promise<string>;
|
|
17
16
|
declare function unsignCookie(input: string, secret: string | null): Promise<string | false>;
|
|
18
17
|
//#endregion
|
|
19
|
-
export { buildCookieJar, createCookieJar, parseCookie, parseCookieRaw, parseCookieRawSync,
|
|
18
|
+
export { buildCookieJar, createCookieJar, parseCookie, parseCookieRaw, parseCookieRawSync, signCookie, signCookieValues, unsignCookie };
|
package/dist/cookie/utils.js
CHANGED
|
@@ -3,8 +3,8 @@ const require_runtime = require('../_virtual/_rolldown/runtime.js');
|
|
|
3
3
|
const require_constants = require('../constants.js');
|
|
4
4
|
const require_utils = require('../utils.js');
|
|
5
5
|
const require_cookie_lib = require('./lib.js');
|
|
6
|
-
const require_cookie_cookie = require('./cookie.js');
|
|
7
6
|
const require_error = require('../error.js');
|
|
7
|
+
const require_cookie_cookie = require('./cookie.js');
|
|
8
8
|
const require_cookie_config = require('./config.js');
|
|
9
9
|
let deuri = require("deuri");
|
|
10
10
|
|
|
@@ -121,26 +121,6 @@ async function signPending(pending) {
|
|
|
121
121
|
property.value = await signCookie(value, secret);
|
|
122
122
|
}
|
|
123
123
|
}
|
|
124
|
-
function serializeCookie(cookies) {
|
|
125
|
-
if (!cookies || !require_utils.isNotEmpty(cookies)) return;
|
|
126
|
-
let set;
|
|
127
|
-
let isArray = false;
|
|
128
|
-
for (const key in cookies) {
|
|
129
|
-
if (!key) continue;
|
|
130
|
-
const property = cookies[key];
|
|
131
|
-
if (!property) continue;
|
|
132
|
-
const value = property.value;
|
|
133
|
-
if (value === void 0 || value === null) continue;
|
|
134
|
-
const v = require_cookie_lib.serialize(key, value, property);
|
|
135
|
-
if (set) if (isArray) set.push(v);
|
|
136
|
-
else {
|
|
137
|
-
set = [set, v];
|
|
138
|
-
isArray = true;
|
|
139
|
-
}
|
|
140
|
-
else set = v;
|
|
141
|
-
}
|
|
142
|
-
return set;
|
|
143
|
-
}
|
|
144
124
|
const removeTrailingEquals = /=+$/g;
|
|
145
125
|
const algorithm = {
|
|
146
126
|
name: "HMAC",
|
|
@@ -184,7 +164,6 @@ exports.createCookieJar = createCookieJar;
|
|
|
184
164
|
exports.parseCookie = parseCookie;
|
|
185
165
|
exports.parseCookieRaw = parseCookieRaw;
|
|
186
166
|
exports.parseCookieRawSync = parseCookieRawSync;
|
|
187
|
-
exports.serializeCookie = serializeCookie;
|
|
188
167
|
exports.signCookie = signCookie;
|
|
189
168
|
exports.signCookieValues = signCookieValues;
|
|
190
169
|
exports.unsignCookie = unsignCookie;
|
package/dist/cookie/utils.mjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { dangerousKeys } from "../constants.mjs";
|
|
2
|
-
import { constantTimeEqual,
|
|
3
|
-
import { parse
|
|
4
|
-
import { Cookie } from "./cookie.mjs";
|
|
2
|
+
import { constantTimeEqual, nullObject } from "../utils.mjs";
|
|
3
|
+
import { parse } from "./lib.mjs";
|
|
5
4
|
import { InvalidCookieSignature } from "../error.mjs";
|
|
5
|
+
import { Cookie } from "./cookie.mjs";
|
|
6
6
|
import { compileCookieConfig, isCookieSigned } from "./config.mjs";
|
|
7
7
|
import { decodeComponent } from "deuri";
|
|
8
8
|
|
|
@@ -119,26 +119,6 @@ async function signPending(pending) {
|
|
|
119
119
|
property.value = await signCookie(value, secret);
|
|
120
120
|
}
|
|
121
121
|
}
|
|
122
|
-
function serializeCookie(cookies) {
|
|
123
|
-
if (!cookies || !isNotEmpty(cookies)) return;
|
|
124
|
-
let set;
|
|
125
|
-
let isArray = false;
|
|
126
|
-
for (const key in cookies) {
|
|
127
|
-
if (!key) continue;
|
|
128
|
-
const property = cookies[key];
|
|
129
|
-
if (!property) continue;
|
|
130
|
-
const value = property.value;
|
|
131
|
-
if (value === void 0 || value === null) continue;
|
|
132
|
-
const v = serialize(key, value, property);
|
|
133
|
-
if (set) if (isArray) set.push(v);
|
|
134
|
-
else {
|
|
135
|
-
set = [set, v];
|
|
136
|
-
isArray = true;
|
|
137
|
-
}
|
|
138
|
-
else set = v;
|
|
139
|
-
}
|
|
140
|
-
return set;
|
|
141
|
-
}
|
|
142
122
|
const removeTrailingEquals = /=+$/g;
|
|
143
123
|
const algorithm = {
|
|
144
124
|
name: "HMAC",
|
|
@@ -177,4 +157,4 @@ async function unsignCookie(input, secret) {
|
|
|
177
157
|
}
|
|
178
158
|
|
|
179
159
|
//#endregion
|
|
180
|
-
export { buildCookieJar, createCookieJar, parseCookie, parseCookieRaw, parseCookieRawSync,
|
|
160
|
+
export { buildCookieJar, createCookieJar, parseCookie, parseCookieRaw, parseCookieRawSync, signCookie, signCookieValues, unsignCookie };
|
package/dist/error.d.ts
CHANGED
|
@@ -85,7 +85,7 @@ declare class ElysiaStatus<const in out Code extends number | keyof StatusMap, T
|
|
|
85
85
|
constructor(code: Code, res: T);
|
|
86
86
|
get status(): number;
|
|
87
87
|
}
|
|
88
|
-
declare const status: <const Code extends number | keyof StatusMap, const T = (Code extends keyof StatusMapBack ? StatusMapBack[Code] : Code)>(code: Code, response?: T) => ElysiaStatus<Code, T, Code extends "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" | "
|
|
88
|
+
declare const status: <const Code extends number | keyof StatusMap, const T = (Code extends keyof StatusMapBack ? StatusMapBack[Code] : Code)>(code: Code, response?: T) => ElysiaStatus<Code, T, Code extends "Bad Request" | "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" | "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" ? {
|
|
89
89
|
readonly Continue: 100;
|
|
90
90
|
readonly 'Switching Protocols': 101;
|
|
91
91
|
readonly Processing: 102;
|
package/dist/handler/fetch.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
2
|
const require_runtime = require('../_virtual/_rolldown/runtime.js');
|
|
3
3
|
const require_utils = require('../utils.js');
|
|
4
|
-
const require_error = require('../error.js');
|
|
5
4
|
const require_adapter_utils = require('../adapter/utils.js');
|
|
5
|
+
const require_error = require('../error.js');
|
|
6
6
|
const require_context = require('../context.js');
|
|
7
7
|
const require_adapter_constants = require('../adapter/constants.js');
|
|
8
8
|
const require_handler_utils = require('./utils.js');
|
package/dist/handler/fetch.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { flattenChain, isNotEmpty, nullObject, requestId } from "../utils.mjs";
|
|
2
|
-
import { NotFound } from "../error.mjs";
|
|
3
2
|
import { handleSet } from "../adapter/utils.mjs";
|
|
3
|
+
import { NotFound } from "../error.mjs";
|
|
4
4
|
import { createContext } from "../context.mjs";
|
|
5
5
|
import { defaultAdapter } from "../adapter/constants.mjs";
|
|
6
6
|
import { cachedResponse, getAsyncIndexes } from "./utils.mjs";
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { StatusMap } from "./constants.js";
|
|
2
2
|
import { ElysiaError, ElysiaStatus, InternalServerError, InvalidCookieSignature, NotFound, ParseError, ValidationError, status, validationDetail } from "./error.js";
|
|
3
3
|
import { Cookie } from "./cookie/cookie.js";
|
|
4
|
-
import { serializeCookie } from "./cookie/
|
|
4
|
+
import { serializeCookie } from "./cookie/serialize.js";
|
|
5
5
|
import { ElysiaFile, file } from "./universal/file.js";
|
|
6
6
|
import { TraceEvent, TraceHandler, TraceListener, TraceProcess, TraceStream } from "./trace.js";
|
|
7
7
|
import { env } from "./universal/env.js";
|
package/dist/index.js
CHANGED
|
@@ -3,12 +3,12 @@ const require_runtime = require('./_virtual/_rolldown/runtime.js');
|
|
|
3
3
|
const require_constants = require('./constants.js');
|
|
4
4
|
const require_universal_file = require('./universal/file.js');
|
|
5
5
|
const require_utils = require('./utils.js');
|
|
6
|
-
const
|
|
6
|
+
const require_cookie_serialize = require('./cookie/serialize.js');
|
|
7
7
|
const require_universal_env = require('./universal/env.js');
|
|
8
8
|
const require_error = require('./error.js');
|
|
9
|
-
const require_cookie_utils = require('./cookie/utils.js');
|
|
10
9
|
const require_context = require('./context.js');
|
|
11
10
|
const require_compile_aot = require('./compile/aot.js');
|
|
11
|
+
const require_cookie_cookie = require('./cookie/cookie.js');
|
|
12
12
|
const require_base = require('./base.js');
|
|
13
13
|
const require_type_elysia_file_type = require('./type/elysia/file-type.js');
|
|
14
14
|
const require_type_index = require('./type/index.js');
|
|
@@ -44,7 +44,7 @@ exports.file = require_universal_file.file;
|
|
|
44
44
|
exports.fileType = require_type_elysia_file_type.fileType;
|
|
45
45
|
exports.form = require_utils.form;
|
|
46
46
|
exports.redirect = require_utils.redirect;
|
|
47
|
-
exports.serializeCookie =
|
|
47
|
+
exports.serializeCookie = require_cookie_serialize.serializeCookie;
|
|
48
48
|
exports.setFileTypeDetector = require_type_elysia_file_type.setFileTypeDetector;
|
|
49
49
|
exports.sse = require_utils.sse;
|
|
50
50
|
exports.status = require_error.status;
|
package/dist/index.mjs
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { StatusMap } from "./constants.mjs";
|
|
2
2
|
import { ElysiaFile, file } from "./universal/file.mjs";
|
|
3
3
|
import { form, redirect, sse } from "./utils.mjs";
|
|
4
|
-
import {
|
|
4
|
+
import { serializeCookie } from "./cookie/serialize.mjs";
|
|
5
5
|
import { env } from "./universal/env.mjs";
|
|
6
6
|
import { ElysiaError, ElysiaStatus, InternalServerError, InvalidCookieSignature, NotFound, ParseError, ValidationError, status, validationDetail } from "./error.mjs";
|
|
7
|
-
import { serializeCookie } from "./cookie/utils.mjs";
|
|
8
7
|
import { createBaseContext, createContext } from "./context.mjs";
|
|
9
8
|
import { Compiled } from "./compile/aot.mjs";
|
|
9
|
+
import { Cookie } from "./cookie/cookie.mjs";
|
|
10
10
|
import { Elysia } from "./base.mjs";
|
|
11
11
|
import { fileType, setFileTypeDetector } from "./type/elysia/file-type.mjs";
|
|
12
12
|
import { TypeSystem, t } from "./type/index.mjs";
|
package/dist/plugin/core.d.ts
CHANGED
|
@@ -65,12 +65,13 @@ interface StubPlan {
|
|
|
65
65
|
* when no replayed handler aliases any of them.
|
|
66
66
|
*/
|
|
67
67
|
reconstruct: boolean;
|
|
68
|
+
/**
|
|
69
|
+
* Stub the request-side cookie machinery (parse / jar / signing in
|
|
70
|
+
* `cookie/utils` + `cookie/config`) when no replayed handler aliases the
|
|
71
|
+
* cookie config (`cc`)
|
|
72
|
+
*/
|
|
73
|
+
cookie: boolean;
|
|
68
74
|
}
|
|
69
|
-
/**
|
|
70
|
-
* The internal runtime modules each stub target maps to, plus the throwing
|
|
71
|
-
* source the bundler swaps in. Paths are matched against both `src/…` (dev /
|
|
72
|
-
* test) and `dist/…` (published) so the alias works in either resolution.
|
|
73
|
-
*/
|
|
74
75
|
declare const STUB_SOURCES: Record<keyof StubPlan, Array<{
|
|
75
76
|
filter: RegExp;
|
|
76
77
|
source: string;
|