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
|
@@ -1,19 +1,20 @@
|
|
|
1
|
+
// @bun
|
|
1
2
|
import { isEmpty } from "../../utils.mjs";
|
|
2
3
|
import { ELYSIA_TYPES } from "../constants.mjs";
|
|
3
4
|
import { Refine, Unsafe } from "../typebox-type.mjs";
|
|
4
5
|
import { Refines, elyType, withMeta } from "./utils.mjs";
|
|
5
6
|
|
|
6
7
|
//#region src/type/elysia/array-buffer.ts
|
|
7
|
-
function bufferType(tag,
|
|
8
|
-
let
|
|
8
|
+
function bufferType(tag, createBase) {
|
|
9
|
+
let base;
|
|
9
10
|
let empty;
|
|
10
11
|
return (property) => {
|
|
11
|
-
|
|
12
|
-
if (!property || isEmpty(property)) return empty ??= Object.freeze(elyType(tag,
|
|
12
|
+
base ??= createBase();
|
|
13
|
+
if (!property || isEmpty(property)) return empty ??= Object.freeze(elyType(tag, base));
|
|
13
14
|
const refines = [];
|
|
14
15
|
if (property.minByteLength !== void 0) refines.push([(value) => value.byteLength >= property.minByteLength, `Expect byte to be more than ${property.minByteLength}`]);
|
|
15
16
|
if (property.maxByteLength !== void 0) refines.push([(value) => value.byteLength <= property.maxByteLength, `Expect byte to be less than ${property.maxByteLength}`]);
|
|
16
|
-
return elyType(tag, withMeta(Refines(
|
|
17
|
+
return elyType(tag, withMeta(Refines(base, refines), property));
|
|
17
18
|
};
|
|
18
19
|
}
|
|
19
20
|
const arrayBuffer = /* @__PURE__ */ bufferType(ELYSIA_TYPES.ArrayBuffer, () => Refine(Unsafe({ "~kind": "ArrayBuffer" }), (value) => value instanceof ArrayBuffer, () => "must be ArrayBuffer"));
|
|
@@ -3,16 +3,16 @@ const require_utils = require('../../utils.js');
|
|
|
3
3
|
const require_type_typebox_type = require('../typebox-type.js');
|
|
4
4
|
|
|
5
5
|
//#region src/type/elysia/keep-config.ts
|
|
6
|
-
const
|
|
6
|
+
const mayCarryCookieConfig = (schema, isProperty = false, seen = /* @__PURE__ */ new Set()) => {
|
|
7
7
|
if (!schema || typeof schema !== "object" || seen.has(schema)) return false;
|
|
8
8
|
seen.add(schema);
|
|
9
|
-
if (schema.config !== void 0 || schema.$ref !== void 0 || schema["~kind"] === "Deferred" || require_utils.compositionKeys.some((key) => Array.isArray(schema[key]) && schema[key].some((member) =>
|
|
10
|
-
if (!
|
|
11
|
-
for (const name in schema.properties) if (
|
|
9
|
+
if (schema.config !== void 0 || schema.$ref !== void 0 || schema["~kind"] === "Deferred" || require_utils.compositionKeys.some((key) => Array.isArray(schema[key]) && schema[key].some((member) => mayCarryCookieConfig(member, isProperty, seen)))) return true;
|
|
10
|
+
if (!isProperty) {
|
|
11
|
+
for (const name in schema.properties) if (mayCarryCookieConfig(schema.properties[name], true)) return true;
|
|
12
12
|
}
|
|
13
13
|
return false;
|
|
14
14
|
};
|
|
15
|
-
const
|
|
15
|
+
const withSources = (schema, sources) => Object.defineProperty(Object.create(Object.getPrototypeOf(schema), Object.getOwnPropertyDescriptors(schema)), "~cookieFrom", {
|
|
16
16
|
value: sources,
|
|
17
17
|
writable: true,
|
|
18
18
|
configurable: true
|
|
@@ -20,13 +20,13 @@ const from = (schema, sources) => Object.defineProperty(Object.create(Object.get
|
|
|
20
20
|
const keep = (build, sourcesOf) => ((...args) => {
|
|
21
21
|
const sources = sourcesOf(...args);
|
|
22
22
|
const result = build(...args);
|
|
23
|
-
if (!sources.some((source) =>
|
|
24
|
-
const built =
|
|
23
|
+
if (!sources.some((source) => mayCarryCookieConfig(source))) return result;
|
|
24
|
+
const built = withSources(result, sources);
|
|
25
25
|
const ref = built.$ref;
|
|
26
26
|
const replaced = sources[0]?.$defs?.[ref];
|
|
27
27
|
if (replaced && built.$defs?.[ref] && built.$defs[ref] !== replaced) built.$defs = {
|
|
28
28
|
...built.$defs,
|
|
29
|
-
[ref]:
|
|
29
|
+
[ref]: withSources(built.$defs[ref], [replaced])
|
|
30
30
|
};
|
|
31
31
|
return built;
|
|
32
32
|
});
|
|
@@ -1,17 +1,18 @@
|
|
|
1
|
+
// @bun
|
|
1
2
|
import { compositionKeys } from "../../utils.mjs";
|
|
2
3
|
import { Composite, Evaluate, Interface, Mapped, Omit, Partial, Pick, ReadonlyObject, Required } from "../typebox-type.mjs";
|
|
3
4
|
|
|
4
5
|
//#region src/type/elysia/keep-config.ts
|
|
5
|
-
const
|
|
6
|
+
const mayCarryCookieConfig = (schema, isProperty = false, seen = /* @__PURE__ */ new Set()) => {
|
|
6
7
|
if (!schema || typeof schema !== "object" || seen.has(schema)) return false;
|
|
7
8
|
seen.add(schema);
|
|
8
|
-
if (schema.config !== void 0 || schema.$ref !== void 0 || schema["~kind"] === "Deferred" || compositionKeys.some((key) => Array.isArray(schema[key]) && schema[key].some((member) =>
|
|
9
|
-
if (!
|
|
10
|
-
for (const name in schema.properties) if (
|
|
9
|
+
if (schema.config !== void 0 || schema.$ref !== void 0 || schema["~kind"] === "Deferred" || compositionKeys.some((key) => Array.isArray(schema[key]) && schema[key].some((member) => mayCarryCookieConfig(member, isProperty, seen)))) return true;
|
|
10
|
+
if (!isProperty) {
|
|
11
|
+
for (const name in schema.properties) if (mayCarryCookieConfig(schema.properties[name], true)) return true;
|
|
11
12
|
}
|
|
12
13
|
return false;
|
|
13
14
|
};
|
|
14
|
-
const
|
|
15
|
+
const withSources = (schema, sources) => Object.defineProperty(Object.create(Object.getPrototypeOf(schema), Object.getOwnPropertyDescriptors(schema)), "~cookieFrom", {
|
|
15
16
|
value: sources,
|
|
16
17
|
writable: true,
|
|
17
18
|
configurable: true
|
|
@@ -19,13 +20,13 @@ const from = (schema, sources) => Object.defineProperty(Object.create(Object.get
|
|
|
19
20
|
const keep = (build, sourcesOf) => ((...args) => {
|
|
20
21
|
const sources = sourcesOf(...args);
|
|
21
22
|
const result = build(...args);
|
|
22
|
-
if (!sources.some((source) =>
|
|
23
|
-
const built =
|
|
23
|
+
if (!sources.some((source) => mayCarryCookieConfig(source))) return result;
|
|
24
|
+
const built = withSources(result, sources);
|
|
24
25
|
const ref = built.$ref;
|
|
25
26
|
const replaced = sources[0]?.$defs?.[ref];
|
|
26
27
|
if (replaced && built.$defs?.[ref] && built.$defs[ref] !== replaced) built.$defs = {
|
|
27
28
|
...built.$defs,
|
|
28
|
-
[ref]:
|
|
29
|
+
[ref]: withSources(built.$defs[ref], [replaced])
|
|
29
30
|
};
|
|
30
31
|
return built;
|
|
31
32
|
});
|
|
@@ -1,11 +1,13 @@
|
|
|
1
|
-
import { TSchemaOptions } from "typebox";
|
|
1
|
+
import { TSchemaOptions, Type } from "typebox";
|
|
2
2
|
|
|
3
3
|
//#region src/type/elysia/numeric-enum.d.ts
|
|
4
4
|
type AssertNumericEnum<T extends Record<string, string | number>> = { [K in keyof T]: K extends number ? string : K extends `${number}` ? string : K extends string ? number : never };
|
|
5
|
+
type NumericEnumValue<T> = Extract<T[keyof T], number>;
|
|
6
|
+
type NumericEnumSchema<T> = Type.TCodec<Type.TRefine<Type.TUnsafe<NumericEnumValue<T> | `${NumericEnumValue<T>}`>>, NumericEnumValue<T>>;
|
|
5
7
|
/**
|
|
6
8
|
* Numeric enum: accepts a numeric string or a number, decodes to the
|
|
7
9
|
* matching enum value.
|
|
8
10
|
*/
|
|
9
|
-
declare function NumericEnum<T extends AssertNumericEnum<T>>(item: T, property?: TSchemaOptions):
|
|
11
|
+
declare function NumericEnum<T extends AssertNumericEnum<T>>(item: T, property?: TSchemaOptions): Readonly<NumericEnumSchema<T>>;
|
|
10
12
|
//#endregion
|
|
11
13
|
export { AssertNumericEnum, NumericEnum };
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { ArrayBufferOptions } from "../types.js";
|
|
2
|
+
import * as _$typebox from "typebox";
|
|
2
3
|
|
|
3
4
|
//#region src/type/elysia/uint8-array.d.ts
|
|
4
|
-
declare const Uint8ArrayType: (property?: ArrayBufferOptions) =>
|
|
5
|
+
declare const Uint8ArrayType: (property?: ArrayBufferOptions) => Readonly<_$typebox.TCodec<_$typebox.TRefine<_$typebox.TUnsafe<Uint8Array<ArrayBufferLike>>>, Uint8Array<ArrayBufferLike>>>;
|
|
5
6
|
//#endregion
|
|
6
7
|
export { Uint8ArrayType };
|
|
@@ -4,8 +4,8 @@ const require_type_typebox_type = require('../typebox-type.js');
|
|
|
4
4
|
const require_type_elysia_array_buffer = require('./array-buffer.js');
|
|
5
5
|
|
|
6
6
|
//#region src/type/elysia/uint8-array.ts
|
|
7
|
-
const
|
|
8
|
-
const uint8Array = /* @__PURE__ */ require_type_elysia_array_buffer.bufferType(require_type_constants.ELYSIA_TYPES.Uint8Array, () => require_type_typebox_type.Codec(require_type_typebox_type.Refine(require_type_typebox_type.Unsafe({ "~kind": "Uint8Array" }),
|
|
7
|
+
const isUint8ArrayOrArrayBuffer = (value) => value instanceof Uint8Array || value instanceof ArrayBuffer;
|
|
8
|
+
const uint8Array = /* @__PURE__ */ require_type_elysia_array_buffer.bufferType(require_type_constants.ELYSIA_TYPES.Uint8Array, () => require_type_typebox_type.Codec(require_type_typebox_type.Refine(require_type_typebox_type.Unsafe({ "~kind": "Uint8Array" }), isUint8ArrayOrArrayBuffer, () => "must be Uint8Array")).Decode((value) => value instanceof Uint8Array ? value : new Uint8Array(value)).Encode((value) => value));
|
|
9
9
|
const Uint8ArrayType = (property) => uint8Array(property);
|
|
10
10
|
|
|
11
11
|
//#endregion
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
+
// @bun
|
|
1
2
|
import { ELYSIA_TYPES } from "../constants.mjs";
|
|
2
3
|
import { Codec, Refine, Unsafe } from "../typebox-type.mjs";
|
|
3
4
|
import { bufferType } from "./array-buffer.mjs";
|
|
4
5
|
|
|
5
6
|
//#region src/type/elysia/uint8-array.ts
|
|
6
|
-
const
|
|
7
|
-
const uint8Array = /* @__PURE__ */ bufferType(ELYSIA_TYPES.Uint8Array, () => Codec(Refine(Unsafe({ "~kind": "Uint8Array" }),
|
|
7
|
+
const isUint8ArrayOrArrayBuffer = (value) => value instanceof Uint8Array || value instanceof ArrayBuffer;
|
|
8
|
+
const uint8Array = /* @__PURE__ */ bufferType(ELYSIA_TYPES.Uint8Array, () => Codec(Refine(Unsafe({ "~kind": "Uint8Array" }), isUint8ArrayOrArrayBuffer, () => "must be Uint8Array")).Decode((value) => value instanceof Uint8Array ? value : new Uint8Array(value)).Encode((value) => value));
|
|
8
9
|
const Uint8ArrayType = (property) => uint8Array(property);
|
|
9
10
|
|
|
10
11
|
//#endregion
|
|
@@ -25,9 +25,9 @@ function createSharedReference(createType) {
|
|
|
25
25
|
const hash = propertyChecksum(property);
|
|
26
26
|
if (hash[1]) return createType(property);
|
|
27
27
|
const h = hash[0];
|
|
28
|
-
const
|
|
28
|
+
const serialized = JSON.stringify(property);
|
|
29
29
|
const bucket = shared.get(h);
|
|
30
|
-
if (bucket?.key ===
|
|
30
|
+
if (bucket?.key === serialized) {
|
|
31
31
|
if (shared.size >= 1024) {
|
|
32
32
|
shared.delete(h);
|
|
33
33
|
shared.set(h, bucket);
|
|
@@ -37,7 +37,7 @@ function createSharedReference(createType) {
|
|
|
37
37
|
const schema = Object.freeze(createType(property));
|
|
38
38
|
if (!bucket && shared.size >= 1024) require_utils.evictOldestHalf(shared);
|
|
39
39
|
shared.set(h, {
|
|
40
|
-
key:
|
|
40
|
+
key: serialized,
|
|
41
41
|
schema
|
|
42
42
|
});
|
|
43
43
|
return schema;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
// @bun
|
|
1
2
|
import { evictOldestHalf, fnv1a } from "../../utils.mjs";
|
|
2
3
|
import { SHARED_REFERENCE_CACHE_LIMIT, copyNonEnumerable, referenceCache } from "../shared.mjs";
|
|
3
4
|
import { Refine } from "../typebox-type.mjs";
|
|
@@ -24,9 +25,9 @@ function createSharedReference(createType) {
|
|
|
24
25
|
const hash = propertyChecksum(property);
|
|
25
26
|
if (hash[1]) return createType(property);
|
|
26
27
|
const h = hash[0];
|
|
27
|
-
const
|
|
28
|
+
const serialized = JSON.stringify(property);
|
|
28
29
|
const bucket = shared.get(h);
|
|
29
|
-
if (bucket?.key ===
|
|
30
|
+
if (bucket?.key === serialized) {
|
|
30
31
|
if (shared.size >= 1024) {
|
|
31
32
|
shared.delete(h);
|
|
32
33
|
shared.set(h, bucket);
|
|
@@ -36,7 +37,7 @@ function createSharedReference(createType) {
|
|
|
36
37
|
const schema = Object.freeze(createType(property));
|
|
37
38
|
if (!bucket && shared.size >= 1024) evictOldestHalf(shared);
|
|
38
39
|
shared.set(h, {
|
|
39
|
-
key:
|
|
40
|
+
key: serialized,
|
|
40
41
|
schema
|
|
41
42
|
});
|
|
42
43
|
return schema;
|
package/dist/type/exports.mjs
CHANGED
package/dist/type/index.mjs
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
// @bun
|
|
1
2
|
import { loadTypeNamespace, markTypeUsed } from "./typebox-type.mjs";
|
|
2
3
|
import { ArrayType } from "./elysia/array.mjs";
|
|
3
4
|
import { StringType } from "./elysia/string.mjs";
|
|
@@ -113,7 +114,7 @@ const t = lazyNamespace(() => loadTypeNamespace().type, {
|
|
|
113
114
|
* `typebox/system` is a subgraph of `typebox/type`, so a static re-export here
|
|
114
115
|
* would pin ~231 KB of the deferral back into the eager graph. The proxy also
|
|
115
116
|
* guarantees Elysia's own `Settings` default lands BEFORE the namespace is
|
|
116
|
-
* handed out, keeping a user's explicit `TypeSystem.Settings.Set(...)` last
|
|
117
|
+
* handed out, keeping a user's explicit `TypeSystem.Settings.Set(...)` last \u2014
|
|
117
118
|
* the ordering the eager `setupTypebox()` used to provide
|
|
118
119
|
*/
|
|
119
120
|
const TypeSystem = lazyNamespace(() => typeSystem(loadTypeNamespace().system), Object.create(null));
|
package/dist/type/shared.mjs
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
// @bun
|
|
1
2
|
import * as type from "typebox/type";
|
|
2
3
|
import { Codec, Composite, Decode, Evaluate, Interface, Intersect, Mapped, Module, Null, Omit, Partial, Pick, ReadonlyObject, Ref, Refine, Required, Undefined, Unsafe } from "typebox/type";
|
|
3
4
|
import * as system from "./typebox-system-lite.mjs";
|
package/dist/type/types.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { ELYSIA_TYPES } from "./constants.js";
|
|
2
1
|
import { CookieOptions } from "../cookie/types.js";
|
|
2
|
+
import { ELYSIA_TYPES } from "./constants.js";
|
|
3
3
|
import { TObjectOptions, TSchemaOptions } from "typebox";
|
|
4
4
|
import { TLocalizedValidationError } from "typebox/error";
|
|
5
5
|
|
package/dist/type/types.mjs
CHANGED
package/dist/type/utils.mjs
CHANGED