elysia 2.0.0-exp.24 → 2.0.0-exp.25
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.
|
@@ -160,10 +160,10 @@ function compileHandlerJit({ method, path, handler, instance, root, hook, adapte
|
|
|
160
160
|
const traceHandlers = hook?.trace ?? void 0;
|
|
161
161
|
const hasTrace = !!traceHandlers?.length;
|
|
162
162
|
const traceCount = hasTrace ? traceHandlers.length : 0;
|
|
163
|
-
const beginTrace = (phase, total) => {
|
|
163
|
+
const beginTrace = (phase, total, name = phase) => {
|
|
164
164
|
if (!hasTrace) return "";
|
|
165
165
|
let s = "";
|
|
166
|
-
for (let i = 0; i < traceCount; i++) s += `rp${i}=tr${i}.${phase}({id:c.rid,event:'${phase}',name
|
|
166
|
+
for (let i = 0; i < traceCount; i++) s += `rp${i}=tr${i}.${phase}({id:c.rid,event:'${phase}',name:${JSON.stringify(name)},begin:performance.now(),total:${total}})\n`;
|
|
167
167
|
return s;
|
|
168
168
|
};
|
|
169
169
|
const endTrace = (errBinding) => {
|
|
@@ -330,7 +330,7 @@ function compileHandlerJit({ method, path, handler, instance, root, hook, adapte
|
|
|
330
330
|
const teeBlock = teeConsumers > 0 && !syncAfterResponse ? `if(_r&&(_r[Symbol.iterator]||_r[Symbol.asyncIterator])&&typeof _r.next==='function'){\nconst _s=await tee(_r,${teeCount})\n_r=_s[0]\n` + (hasAfterResponse ? `_stl=_s[1]\n` : "") + (hasTrace ? `_trs=_s[${1 + (hasAfterResponse ? 1 : 0)}]\n` : "") + `}\n` : "";
|
|
331
331
|
if (hasTrace) {
|
|
332
332
|
const handleName = handler?.name && typeof handler.name === "string" ? handler.name : "anonymous";
|
|
333
|
-
code += beginTrace("handle", 1);
|
|
333
|
+
code += beginTrace("handle", 1, handleName);
|
|
334
334
|
const handleChild = buildReport("handle").resolveChild(handleName);
|
|
335
335
|
code += handleChild.begin;
|
|
336
336
|
if (hasBeforeHandle) code += `if(_r===undefined){\n${callHandler}${teeBlock}}\n`;
|
|
@@ -159,10 +159,10 @@ function compileHandlerJit({ method, path, handler, instance, root, hook, adapte
|
|
|
159
159
|
const traceHandlers = hook?.trace ?? void 0;
|
|
160
160
|
const hasTrace = !!traceHandlers?.length;
|
|
161
161
|
const traceCount = hasTrace ? traceHandlers.length : 0;
|
|
162
|
-
const beginTrace = (phase, total) => {
|
|
162
|
+
const beginTrace = (phase, total, name = phase) => {
|
|
163
163
|
if (!hasTrace) return "";
|
|
164
164
|
let s = "";
|
|
165
|
-
for (let i = 0; i < traceCount; i++) s += `rp${i}=tr${i}.${phase}({id:c.rid,event:'${phase}',name
|
|
165
|
+
for (let i = 0; i < traceCount; i++) s += `rp${i}=tr${i}.${phase}({id:c.rid,event:'${phase}',name:${JSON.stringify(name)},begin:performance.now(),total:${total}})\n`;
|
|
166
166
|
return s;
|
|
167
167
|
};
|
|
168
168
|
const endTrace = (errBinding) => {
|
|
@@ -329,7 +329,7 @@ function compileHandlerJit({ method, path, handler, instance, root, hook, adapte
|
|
|
329
329
|
const teeBlock = teeConsumers > 0 && !syncAfterResponse ? `if(_r&&(_r[Symbol.iterator]||_r[Symbol.asyncIterator])&&typeof _r.next==='function'){\nconst _s=await tee(_r,${teeCount})\n_r=_s[0]\n` + (hasAfterResponse ? `_stl=_s[1]\n` : "") + (hasTrace ? `_trs=_s[${1 + (hasAfterResponse ? 1 : 0)}]\n` : "") + `}\n` : "";
|
|
330
330
|
if (hasTrace) {
|
|
331
331
|
const handleName = handler?.name && typeof handler.name === "string" ? handler.name : "anonymous";
|
|
332
|
-
code += beginTrace("handle", 1);
|
|
332
|
+
code += beginTrace("handle", 1, handleName);
|
|
333
333
|
const handleChild = buildReport("handle").resolveChild(handleName);
|
|
334
334
|
code += handleChild.begin;
|
|
335
335
|
if (hasBeforeHandle) code += `if(_r===undefined){\n${callHandler}${teeBlock}}\n`;
|
package/dist/type/bridge.d.ts
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import { Intersect as Intersect$
|
|
1
|
+
import { Intersect as Intersect$1 } from "./elysia/intersect.js";
|
|
2
2
|
import { applyCoercions as applyCoercions$1, coerceBody as coerceBody$1, coerceFormData as coerceFormData$1, coerceQuery as coerceQuery$1, coerceRoot as coerceRoot$1, coerceStringToStructure as coerceStringToStructure$1 } from "./coerce.js";
|
|
3
3
|
import { hasTypes as hasTypes$1 } from "./utils.js";
|
|
4
4
|
import { TypeBoxValidatorCache as TypeBoxValidatorCache$1 } from "./validator/validator-cache.js";
|
|
5
5
|
import { TypeBoxValidator as TypeBoxValidator$1 } from "./validator/index.js";
|
|
6
|
-
import { Compile as Compile$1 } from "typebox/compile";
|
|
7
6
|
import { Ref as Ref$1, TAny, TSchema } from "typebox/type";
|
|
8
|
-
import {
|
|
7
|
+
import { Compile as Compile$1 } from "typebox/compile";
|
|
8
|
+
import { Decode as Decode$1, Default as Default$1, HasCodec as HasCodec$1 } from "typebox/value";
|
|
9
9
|
|
|
10
10
|
//#region src/type/bridge.d.ts
|
|
11
11
|
interface TypeboxModule {
|
|
12
12
|
Compile: typeof Compile$1;
|
|
13
|
-
Decode: typeof Decode$
|
|
13
|
+
Decode: typeof Decode$1;
|
|
14
14
|
applyCoercions: typeof applyCoercions$1;
|
|
15
15
|
TypeBoxValidator: TypeBoxValidator$1;
|
|
16
16
|
TypeBoxValidatorCache: TypeBoxValidatorCache$1;
|
|
@@ -21,12 +21,12 @@ interface TypeboxModule {
|
|
|
21
21
|
coerceBody: typeof coerceBody$1;
|
|
22
22
|
hasTypes: typeof hasTypes$1;
|
|
23
23
|
HasCodec: typeof HasCodec$1;
|
|
24
|
-
Intersect: typeof Intersect$
|
|
24
|
+
Intersect: typeof Intersect$1;
|
|
25
25
|
Default: typeof Default$1;
|
|
26
26
|
Ref: typeof Ref$1;
|
|
27
27
|
}
|
|
28
28
|
declare let Compile: typeof Compile$1;
|
|
29
|
-
declare let Decode: typeof Decode$
|
|
29
|
+
declare let Decode: typeof Decode$1;
|
|
30
30
|
declare let applyCoercions: typeof applyCoercions$1;
|
|
31
31
|
declare let TypeBoxValidator: TypeBoxValidator$1;
|
|
32
32
|
type TypeBoxValidator<T extends TSchema = TAny> = TypeBoxValidator$1<T>;
|
|
@@ -39,7 +39,7 @@ declare let coerceStringToStructure: typeof coerceStringToStructure$1;
|
|
|
39
39
|
declare let coerceBody: typeof coerceBody$1;
|
|
40
40
|
declare let hasTypes: typeof hasTypes$1;
|
|
41
41
|
declare let HasCodec: typeof HasCodec$1;
|
|
42
|
-
declare let Intersect: typeof Intersect$
|
|
42
|
+
declare let Intersect: typeof Intersect$1;
|
|
43
43
|
declare let Default: typeof Default$1;
|
|
44
44
|
declare let Ref: typeof Ref$1;
|
|
45
45
|
declare function useTypebox(mod: TypeboxModule): void;
|
package/dist/type/types.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { ELYSIA_TYPES } from "./constants.js";
|
|
2
2
|
import { CookieOptions } from "../cookie/types.js";
|
|
3
3
|
import { MaybeArray } from "../types.js";
|
|
4
|
-
import { Validator } from "typebox/schema";
|
|
5
4
|
import { TObjectOptions, TSchemaOptions } from "typebox";
|
|
6
5
|
import { TLocalizedValidationError } from "typebox/error";
|
|
6
|
+
import { Validator } from "typebox/schema";
|
|
7
7
|
|
|
8
8
|
//#region src/type/types.d.ts
|
|
9
9
|
type FileUnit = number | `${number}${'k' | 'm'}`;
|
|
@@ -2,8 +2,8 @@ import { Validator as Validator$1, ValidatorOptions } from "../../validator/inde
|
|
|
2
2
|
import { TypeBoxValidatorCache } from "./validator-cache.js";
|
|
3
3
|
import { MaybePromise } from "../../types.js";
|
|
4
4
|
import { Static, StaticDecode, StaticEncode, TAny, TSchema } from "typebox/type";
|
|
5
|
-
import { Validator } from "typebox/schema";
|
|
6
5
|
import { TLocalizedValidationError } from "typebox/error";
|
|
6
|
+
import { Validator } from "typebox/schema";
|
|
7
7
|
|
|
8
8
|
//#region src/type/validator/index.d.ts
|
|
9
9
|
declare function shallowMergeObjects(members: any[]): TSchema | null;
|
package/dist/types.d.ts
CHANGED
|
@@ -10,8 +10,8 @@ import { Context, ErrorContext, LifecycleContext, PreContext } from "./context.j
|
|
|
10
10
|
import { WebSocketHandler } from "./ws/types.js";
|
|
11
11
|
import { AnyElysia, Elysia } from "./base.js";
|
|
12
12
|
import { ElysiaAdapter } from "./adapter/index.js";
|
|
13
|
-
import { Instruction } from "exact-mirror";
|
|
14
13
|
import { Static, StaticDecode, StaticEncode, TIntersect, TObject, TSchema } from "typebox";
|
|
14
|
+
import { Instruction } from "exact-mirror";
|
|
15
15
|
import { OpenAPIV3 } from "openapi-types";
|
|
16
16
|
|
|
17
17
|
//#region src/types.d.ts
|