elysia 2.0.0-beta.3 → 2.0.0-beta.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/README.md +1 -1
- package/dist/_virtual/_rolldown/runtime.mjs +1 -0
- package/dist/adapter/bun/index.d.ts +16 -2
- package/dist/adapter/bun/index.js +458 -119
- package/dist/adapter/bun/index.mjs +459 -121
- 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.js +0 -57
- package/dist/adapter/origin.mjs +1 -57
- package/dist/adapter/response-ownership.mjs +1 -0
- package/dist/adapter/skip-clone.mjs +1 -0
- package/dist/adapter/types.d.ts +2 -21
- package/dist/adapter/types.mjs +1 -0
- package/dist/adapter/utils.d.ts +11 -3
- package/dist/adapter/utils.js +147 -112
- package/dist/adapter/utils.mjs +149 -114
- package/dist/adapter/web-standard/handler.d.ts +1 -1
- package/dist/adapter/web-standard/handler.js +39 -36
- package/dist/adapter/web-standard/handler.mjs +41 -37
- package/dist/adapter/web-standard/index.js +2 -30
- package/dist/adapter/web-standard/index.mjs +3 -30
- package/dist/adapter/web-standard/utils.js +5 -18
- package/dist/adapter/web-standard/utils.mjs +6 -18
- package/dist/base.d.ts +387 -207
- package/dist/base.js +742 -676
- package/dist/base.mjs +747 -680
- package/dist/compile/aot-capture.d.ts +2 -13
- package/dist/compile/aot-capture.js +39 -89
- package/dist/compile/aot-capture.mjs +43 -88
- package/dist/compile/aot-emit.d.ts +9 -8
- package/dist/compile/aot-emit.js +36 -38
- package/dist/compile/aot-emit.mjs +37 -38
- package/dist/compile/aot-reconstruct.js +7 -30
- package/dist/compile/aot-reconstruct.mjs +8 -30
- package/dist/compile/aot.d.ts +15 -17
- package/dist/compile/aot.js +36 -58
- package/dist/compile/aot.mjs +34 -57
- package/dist/compile/handler/descriptor.d.ts +10 -17
- package/dist/compile/handler/descriptor.js +25 -58
- package/dist/compile/handler/descriptor.mjs +29 -58
- package/dist/compile/handler/frozen-validator.d.ts +7 -12
- package/dist/compile/handler/frozen-validator.js +57 -118
- package/dist/compile/handler/frozen-validator.mjs +56 -118
- package/dist/compile/handler/index.d.ts +8 -4
- package/dist/compile/handler/index.js +322 -206
- package/dist/compile/handler/index.mjs +324 -211
- package/dist/compile/handler/jit.d.ts +28 -21
- package/dist/compile/handler/jit.js +232 -159
- package/dist/compile/handler/jit.mjs +235 -165
- package/dist/compile/handler/params.d.ts +5 -4
- package/dist/compile/handler/params.js +21 -9
- package/dist/compile/handler/params.mjs +25 -12
- package/dist/compile/handler/reconstruct.d.ts +4 -4
- package/dist/compile/handler/reconstruct.js +8 -6
- package/dist/compile/handler/reconstruct.mjs +9 -6
- package/dist/compile/handler/static-clone-resolver.d.ts +6 -0
- package/dist/compile/handler/static-clone-resolver.js +8 -0
- package/dist/compile/handler/static-clone-resolver.mjs +8 -0
- package/dist/compile/handler/utils.d.ts +29 -11
- package/dist/compile/handler/utils.js +184 -276
- package/dist/compile/handler/utils.mjs +179 -275
- package/dist/compile/jit-probe.d.ts +2 -2
- package/dist/compile/jit-probe.js +2 -3
- package/dist/compile/jit-probe.mjs +3 -3
- package/dist/compile/lexer.d.ts +7 -4
- package/dist/compile/lexer.js +268 -6
- package/dist/compile/lexer.mjs +269 -4
- package/dist/compile/utils.d.ts +2 -1
- package/dist/compile/utils.js +14 -6
- package/dist/compile/utils.mjs +14 -6
- package/dist/compiled.d.ts +0 -1
- package/dist/compiled.js +0 -10
- package/dist/compiled.mjs +1 -10
- package/dist/constants.js +19 -4
- package/dist/constants.mjs +20 -4
- package/dist/context.d.ts +15 -5
- package/dist/context.js +17 -36
- package/dist/context.mjs +20 -38
- package/dist/cookie/config.d.ts +6 -2
- package/dist/cookie/config.js +77 -23
- package/dist/cookie/config.mjs +79 -25
- package/dist/cookie/cookie.d.ts +7 -5
- package/dist/cookie/cookie.js +12 -10
- package/dist/cookie/cookie.mjs +13 -10
- package/dist/cookie/crypto.d.ts +1 -1
- package/dist/cookie/crypto.js +19 -14
- package/dist/cookie/crypto.mjs +20 -14
- package/dist/cookie/error.d.ts +1 -2
- package/dist/cookie/error.js +6 -3
- package/dist/cookie/error.mjs +7 -3
- package/dist/cookie/lib.js +2 -1
- package/dist/cookie/lib.mjs +3 -1
- package/dist/cookie/serialize.mjs +1 -0
- package/dist/cookie/types.d.ts +1 -1
- package/dist/cookie/types.mjs +1 -0
- package/dist/cookie/utils.d.ts +5 -9
- package/dist/cookie/utils.js +109 -83
- package/dist/cookie/utils.mjs +112 -84
- package/dist/error.d.ts +127 -111
- package/dist/error.js +187 -180
- package/dist/error.mjs +185 -181
- package/dist/generation.d.ts +2 -2
- package/dist/generation.mjs +1 -0
- package/dist/handler/error.d.ts +18 -18
- package/dist/handler/error.js +77 -120
- package/dist/handler/error.mjs +80 -122
- package/dist/handler/fetch.js +165 -153
- package/dist/handler/fetch.mjs +168 -155
- package/dist/handler/utils.d.ts +25 -6
- package/dist/handler/utils.js +81 -26
- package/dist/handler/utils.mjs +76 -25
- package/dist/index.d.ts +11 -11
- package/dist/index.js +3 -1
- package/dist/index.mjs +5 -4
- package/dist/memory.js +2 -2
- package/dist/memory.mjs +3 -2
- package/dist/package.js +1 -1
- package/dist/package.mjs +2 -1
- package/dist/parse-query.js +76 -80
- package/dist/parse-query.mjs +77 -80
- package/dist/plugin/aot/bun.d.ts +8 -1
- package/dist/plugin/aot/bun.js +9 -28
- package/dist/plugin/aot/bun.mjs +11 -29
- package/dist/plugin/aot/core.d.ts +37 -66
- package/dist/plugin/aot/core.js +197 -153
- package/dist/plugin/aot/core.mjs +195 -156
- package/dist/plugin/aot/esbuild.js +8 -24
- package/dist/plugin/aot/esbuild.mjs +10 -25
- package/dist/plugin/aot/hooks.d.ts +6 -17
- package/dist/plugin/aot/hooks.js +37 -17
- package/dist/plugin/aot/hooks.mjs +38 -19
- package/dist/plugin/aot/rspack-loader.d.ts +1 -5
- package/dist/plugin/aot/rspack-loader.js +1 -26
- package/dist/plugin/aot/rspack-loader.mjs +2 -26
- package/dist/plugin/aot/rspack.js +2 -19
- package/dist/plugin/aot/rspack.mjs +4 -20
- package/dist/plugin/aot/source.d.ts +7 -43
- package/dist/plugin/aot/source.js +73 -73
- package/dist/plugin/aot/source.mjs +74 -74
- package/dist/plugin/aot/treeshake.js +2 -6
- package/dist/plugin/aot/treeshake.mjs +3 -6
- package/dist/plugin/aot/unplugin.d.ts +1 -4
- package/dist/plugin/aot/unplugin.js +4 -32
- package/dist/plugin/aot/unplugin.mjs +5 -32
- package/dist/plugin/aot/vite.d.ts +2 -6
- package/dist/plugin/aot/vite.js +0 -14
- package/dist/plugin/aot/vite.mjs +1 -14
- package/dist/plugin/aot/worker.js +2 -2
- package/dist/plugin/aot/worker.mjs +3 -2
- package/dist/plugin/auto-head.js +1 -10
- package/dist/plugin/auto-head.mjs +2 -10
- package/dist/plugin/trace.d.ts +18 -1
- package/dist/plugin/trace.js +0 -16
- package/dist/plugin/trace.mjs +1 -16
- package/dist/plugin/websocket.d.ts +21 -0
- package/dist/plugin/websocket.js +0 -21
- package/dist/plugin/websocket.mjs +1 -21
- package/dist/route-table.d.ts +3 -0
- package/dist/route-table.js +4 -1
- package/dist/route-table.mjs +5 -1
- package/dist/schema-snapshot.d.ts +0 -4
- package/dist/schema-snapshot.js +60 -56
- package/dist/schema-snapshot.mjs +61 -56
- package/dist/sucrose.d.ts +7 -56
- package/dist/sucrose.js +103 -735
- package/dist/sucrose.mjs +103 -728
- package/dist/trace.d.ts +16 -10
- package/dist/trace.js +20 -134
- package/dist/trace.mjs +22 -135
- package/dist/type/bridge-live.d.ts +5 -3
- package/dist/type/bridge-live.js +6 -3
- package/dist/type/bridge-live.mjs +6 -3
- package/dist/type/bridge.d.ts +7 -5
- package/dist/type/bridge.js +38 -28
- package/dist/type/bridge.mjs +27 -22
- package/dist/type/coerce-plan.d.ts +5 -5
- package/dist/type/coerce-plan.js +53 -43
- package/dist/type/coerce-plan.mjs +56 -44
- package/dist/type/coerce.d.ts +3 -7
- package/dist/type/coerce.js +18 -79
- package/dist/type/coerce.mjs +20 -80
- package/dist/type/compat.js +10 -19
- package/dist/type/compat.mjs +12 -20
- 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 +6 -2
- package/dist/type/elysia/array-buffer.js +16 -15
- package/dist/type/elysia/array-buffer.mjs +17 -16
- package/dist/type/elysia/array-string.js +2 -43
- package/dist/type/elysia/array-string.mjs +3 -43
- package/dist/type/elysia/array.js +5 -9
- package/dist/type/elysia/array.mjs +6 -9
- package/dist/type/elysia/boolean-string.mjs +1 -0
- package/dist/type/elysia/boolean.js +3 -13
- package/dist/type/elysia/boolean.mjs +4 -13
- package/dist/type/elysia/cookie.d.ts +3 -4
- package/dist/type/elysia/cookie.js +3 -14
- package/dist/type/elysia/cookie.mjs +4 -14
- package/dist/type/elysia/date.d.ts +2 -1
- package/dist/type/elysia/date.js +7 -14
- package/dist/type/elysia/date.mjs +8 -14
- package/dist/type/elysia/file-type.d.ts +2 -2
- package/dist/type/elysia/file-type.js +4 -3
- package/dist/type/elysia/file-type.mjs +5 -3
- package/dist/type/elysia/file.d.ts +1 -3
- package/dist/type/elysia/file.js +3 -23
- package/dist/type/elysia/file.mjs +5 -10
- package/dist/type/elysia/files.js +1 -7
- package/dist/type/elysia/files.mjs +3 -8
- package/dist/type/elysia/form.mjs +1 -0
- package/dist/type/elysia/integer-string.d.ts +1 -1
- package/dist/type/elysia/integer-string.js +3 -28
- package/dist/type/elysia/integer-string.mjs +5 -29
- package/dist/type/elysia/integer.js +3 -13
- package/dist/type/elysia/integer.mjs +4 -13
- package/dist/type/elysia/intersect.js +0 -5
- package/dist/type/elysia/intersect.mjs +1 -5
- package/dist/type/elysia/json-string.d.ts +7 -0
- package/dist/type/elysia/json-string.js +47 -0
- package/dist/type/elysia/json-string.mjs +47 -0
- package/dist/type/elysia/keep-config.d.ts +14 -0
- package/dist/type/elysia/keep-config.js +62 -0
- package/dist/type/elysia/keep-config.mjs +54 -0
- 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.d.ts +2 -1
- package/dist/type/elysia/number.js +19 -12
- package/dist/type/elysia/number.mjs +19 -12
- package/dist/type/elysia/numeric-enum.d.ts +5 -3
- package/dist/type/elysia/numeric-enum.js +1 -5
- package/dist/type/elysia/numeric-enum.mjs +2 -5
- package/dist/type/elysia/numeric.d.ts +4 -2
- package/dist/type/elysia/numeric.js +17 -14
- package/dist/type/elysia/numeric.mjs +17 -14
- package/dist/type/elysia/object-string.js +2 -40
- package/dist/type/elysia/object-string.mjs +3 -40
- package/dist/type/elysia/object.js +5 -9
- package/dist/type/elysia/object.mjs +6 -9
- package/dist/type/elysia/optional.js +8 -8
- package/dist/type/elysia/optional.mjs +8 -7
- package/dist/type/elysia/problem.d.ts +20 -0
- package/dist/type/elysia/problem.js +19 -0
- package/dist/type/elysia/problem.mjs +19 -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 +4 -18
- package/dist/type/elysia/uint8-array.mjs +5 -18
- package/dist/type/elysia/union-enum.js +5 -6
- package/dist/type/elysia/union-enum.mjs +6 -6
- package/dist/type/elysia/union.js +0 -5
- package/dist/type/elysia/union.mjs +1 -5
- package/dist/type/elysia/utils.d.ts +4 -6
- package/dist/type/elysia/utils.js +16 -40
- package/dist/type/elysia/utils.mjs +15 -36
- package/dist/type/exports.d.ts +4 -2
- package/dist/type/exports.js +13 -1
- package/dist/type/exports.mjs +5 -2
- package/dist/type/index.d.ts +1 -1
- package/dist/type/index.js +31 -23
- package/dist/type/index.mjs +33 -24
- package/dist/type/shared.d.ts +12 -10
- package/dist/type/shared.js +75 -109
- package/dist/type/shared.mjs +72 -108
- package/dist/type/sync-require.d.ts +11 -0
- package/dist/type/sync-require.js +7 -0
- package/dist/type/sync-require.mjs +6 -0
- package/dist/type/typebox-system-lite.d.ts +2 -0
- package/dist/type/typebox-system-lite.js +34 -0
- package/dist/type/typebox-system-lite.mjs +4 -0
- package/dist/type/typebox-system-require.d.ts +7 -0
- package/dist/type/typebox-system-require.js +24 -0
- package/dist/type/typebox-system-require.mjs +24 -0
- package/dist/type/typebox-type-live.d.ts +6 -4
- package/dist/type/typebox-type-live.js +23 -9
- package/dist/type/typebox-type-live.mjs +11 -6
- package/dist/type/typebox-type.d.ts +14 -4
- package/dist/type/typebox-type.js +85 -22
- package/dist/type/typebox-type.mjs +35 -21
- package/dist/type/typebox-value-live.d.ts +3 -1
- package/dist/type/typebox-value-live.js +5 -1
- package/dist/type/typebox-value-live.mjs +4 -1
- package/dist/type/typebox-value-ops.d.ts +4 -0
- package/dist/type/typebox-value-ops.js +90 -0
- package/dist/type/typebox-value-ops.mjs +6 -0
- package/dist/type/typebox-value-require.d.ts +8 -0
- package/dist/type/typebox-value-require.js +28 -0
- package/dist/type/typebox-value-require.mjs +25 -0
- package/dist/type/typebox-value.d.ts +9 -4
- package/dist/type/typebox-value.js +19 -8
- package/dist/type/typebox-value.mjs +19 -9
- package/dist/type/types.d.ts +1 -1
- package/dist/type/types.mjs +1 -0
- package/dist/type/utils.js +1 -10
- package/dist/type/utils.mjs +2 -10
- package/dist/type/validator/clean-safe.d.ts +2 -4
- package/dist/type/validator/clean-safe.js +15 -11
- package/dist/type/validator/clean-safe.mjs +17 -10
- package/dist/type/validator/custom-error.js +50 -48
- package/dist/type/validator/custom-error.mjs +51 -48
- package/dist/type/validator/default-precompute.d.ts +10 -2
- package/dist/type/validator/default-precompute.js +33 -77
- package/dist/type/validator/default-precompute.mjs +33 -77
- package/dist/type/validator/exact-mirror-live.d.ts +8 -0
- package/dist/type/validator/exact-mirror-live.js +15 -0
- package/dist/type/validator/exact-mirror-live.mjs +11 -0
- package/dist/type/validator/exact-mirror-require.d.ts +4 -0
- package/dist/type/validator/exact-mirror-require.js +11 -0
- package/dist/type/validator/exact-mirror-require.mjs +9 -0
- package/dist/type/validator/exact-mirror.js +15 -7
- package/dist/type/validator/exact-mirror.mjs +17 -7
- package/dist/type/validator/frozen-check.js +7 -8
- package/dist/type/validator/frozen-check.mjs +9 -9
- package/dist/type/validator/index.d.ts +2 -1
- package/dist/type/validator/index.js +149 -168
- package/dist/type/validator/index.mjs +155 -173
- package/dist/type/validator/string-codec-aot.d.ts +3 -2
- package/dist/type/validator/string-codec-aot.js +11 -7
- package/dist/type/validator/string-codec-aot.mjs +11 -7
- package/dist/type/validator/validator-cache.d.ts +5 -4
- package/dist/type/validator/validator-cache.js +49 -37
- package/dist/type/validator/validator-cache.mjs +49 -36
- package/dist/types.d.ts +596 -187
- package/dist/types.mjs +1 -0
- package/dist/universal/constants.mjs +1 -0
- package/dist/universal/env.js +2 -3
- package/dist/universal/env.mjs +2 -3
- package/dist/universal/file.d.ts +6 -4
- package/dist/universal/file.js +7 -19
- package/dist/universal/file.mjs +9 -19
- package/dist/universal/index.d.ts +2 -2
- package/dist/universal/index.mjs +1 -0
- package/dist/universal/is-production.d.ts +1 -2
- package/dist/universal/is-production.js +1 -3
- package/dist/universal/is-production.mjs +3 -3
- package/dist/universal/server.d.ts +0 -272
- package/dist/universal/server.mjs +1 -0
- package/dist/utils.d.ts +62 -22
- package/dist/utils.js +342 -277
- package/dist/utils.mjs +327 -273
- package/dist/validator/index.d.ts +3 -3
- package/dist/validator/index.js +20 -34
- package/dist/validator/index.mjs +23 -36
- package/dist/validator/route.d.ts +3 -10
- package/dist/validator/route.js +2 -1
- package/dist/validator/route.mjs +3 -1
- package/dist/ws/context.d.ts +4 -1
- package/dist/ws/context.js +41 -36
- package/dist/ws/context.mjs +41 -36
- package/dist/ws/index.mjs +1 -0
- package/dist/ws/parser.js +12 -22
- package/dist/ws/parser.mjs +13 -22
- package/dist/ws/route.d.ts +2 -2
- package/dist/ws/route.js +295 -221
- package/dist/ws/route.mjs +302 -227
- package/dist/ws/types.d.ts +6 -7
- package/dist/ws/types.mjs +1 -0
- package/package.json +22 -55
- package/dist/compile/analysis-cache.d.ts +0 -6
- package/dist/compile/analysis-cache.js +0 -12
- package/dist/compile/analysis-cache.mjs +0 -11
- package/dist/cookie/index.d.ts +0 -7
- package/dist/cookie/index.js +0 -13
- package/dist/cookie/index.mjs +0 -7
- package/dist/handler/index.d.ts +0 -2
- package/dist/handler/index.js +0 -5
- package/dist/handler/index.mjs +0 -3
package/dist/schema-snapshot.js
CHANGED
|
@@ -52,8 +52,7 @@ function isImmutableNode(value) {
|
|
|
52
52
|
immutableNodes.set(value, immutable);
|
|
53
53
|
return immutable;
|
|
54
54
|
}
|
|
55
|
-
|
|
56
|
-
function deepCloneSchema(value, seen, canShare = true) {
|
|
55
|
+
function deepCloneSchema(value, freeze, seen, canShare = true) {
|
|
57
56
|
if (value === null || typeof value !== "object") return value;
|
|
58
57
|
const cached = seen?.get(value);
|
|
59
58
|
if (cached) return cached;
|
|
@@ -61,8 +60,8 @@ function deepCloneSchema(value, seen, canShare = true) {
|
|
|
61
60
|
const out = [];
|
|
62
61
|
seen ??= /* @__PURE__ */ new Map();
|
|
63
62
|
seen.set(value, out);
|
|
64
|
-
for (let i = 0; i < value.length; i++) out[i] = deepCloneSchema(value[i], seen);
|
|
65
|
-
return
|
|
63
|
+
for (let i = 0; i < value.length; i++) out[i] = deepCloneSchema(value[i], freeze, seen);
|
|
64
|
+
return freeze ? Object.freeze(out) : out;
|
|
66
65
|
}
|
|
67
66
|
if (canShare && isImmutableNode(value)) return value;
|
|
68
67
|
const proto = Object.getPrototypeOf(value);
|
|
@@ -77,14 +76,14 @@ function deepCloneSchema(value, seen, canShare = true) {
|
|
|
77
76
|
const property = value[key];
|
|
78
77
|
if (!allEnumerable && !isEnumerable.call(value, key)) {
|
|
79
78
|
Object.defineProperty(out, key, {
|
|
80
|
-
value: property,
|
|
79
|
+
value: key === "~cookieFrom" ? deepCloneSchema(property, freeze, seen) : property,
|
|
81
80
|
enumerable: false,
|
|
82
81
|
writable: true,
|
|
83
82
|
configurable: true
|
|
84
83
|
});
|
|
85
84
|
continue;
|
|
86
85
|
}
|
|
87
|
-
const cloned = deepCloneSchema(property, seen);
|
|
86
|
+
const cloned = deepCloneSchema(property, freeze, seen);
|
|
88
87
|
if (key === "__proto__") Object.defineProperty(out, key, {
|
|
89
88
|
value: cloned,
|
|
90
89
|
enumerable: true,
|
|
@@ -97,7 +96,7 @@ function deepCloneSchema(value, seen, canShare = true) {
|
|
|
97
96
|
for (let i = 0; i < symbols.length; i++) {
|
|
98
97
|
const key = symbols[i];
|
|
99
98
|
const property = value[key];
|
|
100
|
-
if (isEnumerable.call(value, key)) out[key] = deepCloneSchema(property, seen);
|
|
99
|
+
if (isEnumerable.call(value, key)) out[key] = deepCloneSchema(property, freeze, seen);
|
|
101
100
|
else Object.defineProperty(out, key, {
|
|
102
101
|
value: property,
|
|
103
102
|
enumerable: false,
|
|
@@ -105,7 +104,7 @@ function deepCloneSchema(value, seen, canShare = true) {
|
|
|
105
104
|
configurable: true
|
|
106
105
|
});
|
|
107
106
|
}
|
|
108
|
-
return
|
|
107
|
+
return freeze ? Object.freeze(out) : out;
|
|
109
108
|
}
|
|
110
109
|
const refIds = /* @__PURE__ */ new WeakMap();
|
|
111
110
|
let nextRefId = 0;
|
|
@@ -114,20 +113,19 @@ function refKey(value) {
|
|
|
114
113
|
if (id === void 0) refIds.set(value, id = ++nextRefId);
|
|
115
114
|
return "r" + id + ";";
|
|
116
115
|
}
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
function fingerprint(value, seen, canShare = true) {
|
|
116
|
+
const byRefKey = (value, state) => value !== null && (typeof value === "object" || typeof value === "function") ? refKey(value) : fingerprint(value, void 0, state);
|
|
117
|
+
function fingerprint(value, seen, state, canShare = true) {
|
|
120
118
|
if (value === null) return "z;";
|
|
121
119
|
const type = typeof value;
|
|
122
120
|
if (type !== "object") switch (type) {
|
|
123
121
|
case "string": return "s" + value.length + ":" + value;
|
|
124
|
-
case "number": return "n" + value + ";";
|
|
122
|
+
case "number": return "n" + (Object.is(value, -0) ? "-0" : value) + ";";
|
|
125
123
|
case "boolean": return value ? "T;" : "F;";
|
|
126
124
|
case "function": return refKey(value);
|
|
127
125
|
case "undefined": return "u;";
|
|
128
126
|
case "bigint": return "g" + value + ";";
|
|
129
127
|
default:
|
|
130
|
-
|
|
128
|
+
state.bail = true;
|
|
131
129
|
return "y;";
|
|
132
130
|
}
|
|
133
131
|
const backReference = seen?.get(value);
|
|
@@ -136,7 +134,7 @@ function fingerprint(value, seen, canShare = true) {
|
|
|
136
134
|
seen ??= /* @__PURE__ */ new Map();
|
|
137
135
|
seen.set(value, seen.size);
|
|
138
136
|
let out = "[";
|
|
139
|
-
for (let i = 0; i < value.length; i++) out += fingerprint(value[i], seen);
|
|
137
|
+
for (let i = 0; i < value.length; i++) out += fingerprint(value[i], seen, state);
|
|
140
138
|
return out + "];";
|
|
141
139
|
}
|
|
142
140
|
if (canShare && isImmutableNode(value)) return refKey(value);
|
|
@@ -151,15 +149,19 @@ function fingerprint(value, seen, canShare = true) {
|
|
|
151
149
|
const key = keys[i];
|
|
152
150
|
const property = value[key];
|
|
153
151
|
out += "k" + key.length + ":" + key;
|
|
154
|
-
|
|
152
|
+
const hidden = !allEnumerable && !isEnumerable.call(value, key);
|
|
153
|
+
out += hidden && key !== "~cookieFrom" ? "!" + byRefKey(property, state) : (hidden ? "~" : "=") + fingerprint(property, seen, state);
|
|
155
154
|
}
|
|
156
|
-
if (Object.getOwnPropertySymbols(value).length)
|
|
155
|
+
if (Object.getOwnPropertySymbols(value).length) state.bail = true;
|
|
157
156
|
return out + "};";
|
|
158
157
|
}
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
158
|
+
function cloneOrWarn(object, freeze) {
|
|
159
|
+
try {
|
|
160
|
+
return deepCloneSchema(object, freeze, void 0, false);
|
|
161
|
+
} catch (error) {
|
|
162
|
+
console.warn("[Elysia] schema snapshot failed; schema kept by reference:", error);
|
|
163
|
+
}
|
|
164
|
+
}
|
|
163
165
|
function snapshotSchema(schema) {
|
|
164
166
|
if (schema === null || typeof schema !== "object") return schema;
|
|
165
167
|
const object = schema;
|
|
@@ -167,21 +169,12 @@ function snapshotSchema(schema) {
|
|
|
167
169
|
if (produced.has(object) && !Object.isFrozen(object)) return schema;
|
|
168
170
|
const existing = modelSnapshots.get(object);
|
|
169
171
|
if (existing) return existing;
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
cloned = deepCloneSchema(object, void 0, false);
|
|
173
|
-
} catch (error) {
|
|
174
|
-
console.warn("[Elysia] schema snapshot failed; schema kept by reference:", error);
|
|
175
|
-
return schema;
|
|
176
|
-
}
|
|
172
|
+
const cloned = cloneOrWarn(object, false);
|
|
173
|
+
if (cloned === void 0) return schema;
|
|
177
174
|
modelSnapshots.set(object, cloned);
|
|
178
175
|
produced.add(cloned);
|
|
179
176
|
return cloned;
|
|
180
177
|
}
|
|
181
|
-
/**
|
|
182
|
-
* The route/guard hook snapshot: deep-frozen, and shared with every
|
|
183
|
-
* structurally identical schema in the process.
|
|
184
|
-
*/
|
|
185
178
|
function internSchema(schema, intern) {
|
|
186
179
|
if (schema === null || typeof schema !== "object") return schema;
|
|
187
180
|
const object = schema;
|
|
@@ -193,11 +186,11 @@ function internSchema(schema, intern) {
|
|
|
193
186
|
if (existing) return existing;
|
|
194
187
|
let key;
|
|
195
188
|
if (intern) {
|
|
196
|
-
|
|
189
|
+
const state = { bail: false };
|
|
197
190
|
try {
|
|
198
|
-
key = fingerprint(object, void 0, false);
|
|
191
|
+
key = fingerprint(object, void 0, state, false);
|
|
199
192
|
} catch {}
|
|
200
|
-
if (
|
|
193
|
+
if (state.bail) key = void 0;
|
|
201
194
|
}
|
|
202
195
|
if (key !== void 0) {
|
|
203
196
|
const shared = interned.get(key);
|
|
@@ -210,16 +203,8 @@ function internSchema(schema, intern) {
|
|
|
210
203
|
return shared;
|
|
211
204
|
}
|
|
212
205
|
}
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
try {
|
|
216
|
-
cloned = deepCloneSchema(object, void 0, false);
|
|
217
|
-
} catch (error) {
|
|
218
|
-
console.warn("[Elysia] schema snapshot failed; schema kept by reference:", error);
|
|
219
|
-
return schema;
|
|
220
|
-
} finally {
|
|
221
|
-
freezeClones = false;
|
|
222
|
-
}
|
|
206
|
+
const cloned = cloneOrWarn(object, true);
|
|
207
|
+
if (cloned === void 0) return schema;
|
|
223
208
|
hookSnapshots.set(object, cloned);
|
|
224
209
|
produced.add(cloned);
|
|
225
210
|
if (key !== void 0) {
|
|
@@ -232,9 +217,34 @@ function snapshotSlots(target, intern) {
|
|
|
232
217
|
for (const slot of schemaSlots) if (target[slot] != null) target[slot] = internSchema(target[slot], intern);
|
|
233
218
|
const response = target.response;
|
|
234
219
|
if (response != null) if (typeof response === "object" && !("~standard" in response) && isStatusMap(response)) {
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
220
|
+
let next = {};
|
|
221
|
+
const state = { bail: false };
|
|
222
|
+
let key = "M";
|
|
223
|
+
for (const status in response) {
|
|
224
|
+
const schema = internSchema(response[status], intern);
|
|
225
|
+
Object.defineProperty(next, status, {
|
|
226
|
+
value: schema,
|
|
227
|
+
enumerable: true
|
|
228
|
+
});
|
|
229
|
+
key += status.length + ":" + status + byRefKey(schema, state);
|
|
230
|
+
}
|
|
231
|
+
if (key === "M") target.response = next;
|
|
232
|
+
else {
|
|
233
|
+
if (intern && !state.bail) {
|
|
234
|
+
const shared = interned.get(key);
|
|
235
|
+
if (shared === void 0) {
|
|
236
|
+
if (interned.size >= INTERN_LIMIT) require_utils.evictOldestHalf(interned);
|
|
237
|
+
interned.set(key, next);
|
|
238
|
+
} else {
|
|
239
|
+
if (interned.size >= INTERN_LIMIT) {
|
|
240
|
+
interned.delete(key);
|
|
241
|
+
interned.set(key, shared);
|
|
242
|
+
}
|
|
243
|
+
next = shared;
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
target.response = Object.freeze(next);
|
|
247
|
+
}
|
|
238
248
|
} else target.response = internSchema(response, intern);
|
|
239
249
|
}
|
|
240
250
|
function isStatusMap(response) {
|
|
@@ -242,18 +252,12 @@ function isStatusMap(response) {
|
|
|
242
252
|
for (const key in response) if (!Number.isInteger(Number(key))) return false;
|
|
243
253
|
return true;
|
|
244
254
|
}
|
|
255
|
+
const hasSlot = (target) => schemaSlots.some((slot) => target[slot] != null) || target.response != null;
|
|
245
256
|
function snapshotHookSchemas(hook) {
|
|
246
257
|
if (!hook) return hook;
|
|
247
|
-
|
|
248
|
-
if (schemaSlots.some((slot) => hook[slot] != null) || hook.response != null) needsCopy = true;
|
|
258
|
+
const needsCopy = hasSlot(hook);
|
|
249
259
|
const schemas = hook.schemas;
|
|
250
|
-
if (!needsCopy && Array.isArray(schemas))
|
|
251
|
-
for (const entry of schemas) if (entry && (schemaSlots.some((slot) => entry[slot] != null) || entry.response != null)) {
|
|
252
|
-
needsCopy = true;
|
|
253
|
-
break;
|
|
254
|
-
}
|
|
255
|
-
}
|
|
256
|
-
if (!needsCopy) return hook;
|
|
260
|
+
if (!needsCopy && !(Array.isArray(schemas) && schemas.some((e) => e && hasSlot(e)))) return hook;
|
|
257
261
|
const intern = !require_universal_env.env.ELYSIA_AOT_BUILD;
|
|
258
262
|
const copy = Object.assign(Object.create(Object.getPrototypeOf(hook)), hook);
|
|
259
263
|
snapshotSlots(copy, intern);
|
package/dist/schema-snapshot.mjs
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
// @bun
|
|
1
2
|
import { evictOldestHalf } from "./utils.mjs";
|
|
2
3
|
import { env } from "./universal/env.mjs";
|
|
3
4
|
|
|
@@ -51,8 +52,7 @@ function isImmutableNode(value) {
|
|
|
51
52
|
immutableNodes.set(value, immutable);
|
|
52
53
|
return immutable;
|
|
53
54
|
}
|
|
54
|
-
|
|
55
|
-
function deepCloneSchema(value, seen, canShare = true) {
|
|
55
|
+
function deepCloneSchema(value, freeze, seen, canShare = true) {
|
|
56
56
|
if (value === null || typeof value !== "object") return value;
|
|
57
57
|
const cached = seen?.get(value);
|
|
58
58
|
if (cached) return cached;
|
|
@@ -60,8 +60,8 @@ function deepCloneSchema(value, seen, canShare = true) {
|
|
|
60
60
|
const out = [];
|
|
61
61
|
seen ??= /* @__PURE__ */ new Map();
|
|
62
62
|
seen.set(value, out);
|
|
63
|
-
for (let i = 0; i < value.length; i++) out[i] = deepCloneSchema(value[i], seen);
|
|
64
|
-
return
|
|
63
|
+
for (let i = 0; i < value.length; i++) out[i] = deepCloneSchema(value[i], freeze, seen);
|
|
64
|
+
return freeze ? Object.freeze(out) : out;
|
|
65
65
|
}
|
|
66
66
|
if (canShare && isImmutableNode(value)) return value;
|
|
67
67
|
const proto = Object.getPrototypeOf(value);
|
|
@@ -76,14 +76,14 @@ function deepCloneSchema(value, seen, canShare = true) {
|
|
|
76
76
|
const property = value[key];
|
|
77
77
|
if (!allEnumerable && !isEnumerable.call(value, key)) {
|
|
78
78
|
Object.defineProperty(out, key, {
|
|
79
|
-
value: property,
|
|
79
|
+
value: key === "~cookieFrom" ? deepCloneSchema(property, freeze, seen) : property,
|
|
80
80
|
enumerable: false,
|
|
81
81
|
writable: true,
|
|
82
82
|
configurable: true
|
|
83
83
|
});
|
|
84
84
|
continue;
|
|
85
85
|
}
|
|
86
|
-
const cloned = deepCloneSchema(property, seen);
|
|
86
|
+
const cloned = deepCloneSchema(property, freeze, seen);
|
|
87
87
|
if (key === "__proto__") Object.defineProperty(out, key, {
|
|
88
88
|
value: cloned,
|
|
89
89
|
enumerable: true,
|
|
@@ -96,7 +96,7 @@ function deepCloneSchema(value, seen, canShare = true) {
|
|
|
96
96
|
for (let i = 0; i < symbols.length; i++) {
|
|
97
97
|
const key = symbols[i];
|
|
98
98
|
const property = value[key];
|
|
99
|
-
if (isEnumerable.call(value, key)) out[key] = deepCloneSchema(property, seen);
|
|
99
|
+
if (isEnumerable.call(value, key)) out[key] = deepCloneSchema(property, freeze, seen);
|
|
100
100
|
else Object.defineProperty(out, key, {
|
|
101
101
|
value: property,
|
|
102
102
|
enumerable: false,
|
|
@@ -104,7 +104,7 @@ function deepCloneSchema(value, seen, canShare = true) {
|
|
|
104
104
|
configurable: true
|
|
105
105
|
});
|
|
106
106
|
}
|
|
107
|
-
return
|
|
107
|
+
return freeze ? Object.freeze(out) : out;
|
|
108
108
|
}
|
|
109
109
|
const refIds = /* @__PURE__ */ new WeakMap();
|
|
110
110
|
let nextRefId = 0;
|
|
@@ -113,20 +113,19 @@ function refKey(value) {
|
|
|
113
113
|
if (id === void 0) refIds.set(value, id = ++nextRefId);
|
|
114
114
|
return "r" + id + ";";
|
|
115
115
|
}
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
function fingerprint(value, seen, canShare = true) {
|
|
116
|
+
const byRefKey = (value, state) => value !== null && (typeof value === "object" || typeof value === "function") ? refKey(value) : fingerprint(value, void 0, state);
|
|
117
|
+
function fingerprint(value, seen, state, canShare = true) {
|
|
119
118
|
if (value === null) return "z;";
|
|
120
119
|
const type = typeof value;
|
|
121
120
|
if (type !== "object") switch (type) {
|
|
122
121
|
case "string": return "s" + value.length + ":" + value;
|
|
123
|
-
case "number": return "n" + value + ";";
|
|
122
|
+
case "number": return "n" + (Object.is(value, -0) ? "-0" : value) + ";";
|
|
124
123
|
case "boolean": return value ? "T;" : "F;";
|
|
125
124
|
case "function": return refKey(value);
|
|
126
125
|
case "undefined": return "u;";
|
|
127
126
|
case "bigint": return "g" + value + ";";
|
|
128
127
|
default:
|
|
129
|
-
|
|
128
|
+
state.bail = true;
|
|
130
129
|
return "y;";
|
|
131
130
|
}
|
|
132
131
|
const backReference = seen?.get(value);
|
|
@@ -135,7 +134,7 @@ function fingerprint(value, seen, canShare = true) {
|
|
|
135
134
|
seen ??= /* @__PURE__ */ new Map();
|
|
136
135
|
seen.set(value, seen.size);
|
|
137
136
|
let out = "[";
|
|
138
|
-
for (let i = 0; i < value.length; i++) out += fingerprint(value[i], seen);
|
|
137
|
+
for (let i = 0; i < value.length; i++) out += fingerprint(value[i], seen, state);
|
|
139
138
|
return out + "];";
|
|
140
139
|
}
|
|
141
140
|
if (canShare && isImmutableNode(value)) return refKey(value);
|
|
@@ -150,15 +149,19 @@ function fingerprint(value, seen, canShare = true) {
|
|
|
150
149
|
const key = keys[i];
|
|
151
150
|
const property = value[key];
|
|
152
151
|
out += "k" + key.length + ":" + key;
|
|
153
|
-
|
|
152
|
+
const hidden = !allEnumerable && !isEnumerable.call(value, key);
|
|
153
|
+
out += hidden && key !== "~cookieFrom" ? "!" + byRefKey(property, state) : (hidden ? "~" : "=") + fingerprint(property, seen, state);
|
|
154
154
|
}
|
|
155
|
-
if (Object.getOwnPropertySymbols(value).length)
|
|
155
|
+
if (Object.getOwnPropertySymbols(value).length) state.bail = true;
|
|
156
156
|
return out + "};";
|
|
157
157
|
}
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
158
|
+
function cloneOrWarn(object, freeze) {
|
|
159
|
+
try {
|
|
160
|
+
return deepCloneSchema(object, freeze, void 0, false);
|
|
161
|
+
} catch (error) {
|
|
162
|
+
console.warn("[Elysia] schema snapshot failed; schema kept by reference:", error);
|
|
163
|
+
}
|
|
164
|
+
}
|
|
162
165
|
function snapshotSchema(schema) {
|
|
163
166
|
if (schema === null || typeof schema !== "object") return schema;
|
|
164
167
|
const object = schema;
|
|
@@ -166,21 +169,12 @@ function snapshotSchema(schema) {
|
|
|
166
169
|
if (produced.has(object) && !Object.isFrozen(object)) return schema;
|
|
167
170
|
const existing = modelSnapshots.get(object);
|
|
168
171
|
if (existing) return existing;
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
cloned = deepCloneSchema(object, void 0, false);
|
|
172
|
-
} catch (error) {
|
|
173
|
-
console.warn("[Elysia] schema snapshot failed; schema kept by reference:", error);
|
|
174
|
-
return schema;
|
|
175
|
-
}
|
|
172
|
+
const cloned = cloneOrWarn(object, false);
|
|
173
|
+
if (cloned === void 0) return schema;
|
|
176
174
|
modelSnapshots.set(object, cloned);
|
|
177
175
|
produced.add(cloned);
|
|
178
176
|
return cloned;
|
|
179
177
|
}
|
|
180
|
-
/**
|
|
181
|
-
* The route/guard hook snapshot: deep-frozen, and shared with every
|
|
182
|
-
* structurally identical schema in the process.
|
|
183
|
-
*/
|
|
184
178
|
function internSchema(schema, intern) {
|
|
185
179
|
if (schema === null || typeof schema !== "object") return schema;
|
|
186
180
|
const object = schema;
|
|
@@ -192,11 +186,11 @@ function internSchema(schema, intern) {
|
|
|
192
186
|
if (existing) return existing;
|
|
193
187
|
let key;
|
|
194
188
|
if (intern) {
|
|
195
|
-
|
|
189
|
+
const state = { bail: false };
|
|
196
190
|
try {
|
|
197
|
-
key = fingerprint(object, void 0, false);
|
|
191
|
+
key = fingerprint(object, void 0, state, false);
|
|
198
192
|
} catch {}
|
|
199
|
-
if (
|
|
193
|
+
if (state.bail) key = void 0;
|
|
200
194
|
}
|
|
201
195
|
if (key !== void 0) {
|
|
202
196
|
const shared = interned.get(key);
|
|
@@ -209,16 +203,8 @@ function internSchema(schema, intern) {
|
|
|
209
203
|
return shared;
|
|
210
204
|
}
|
|
211
205
|
}
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
try {
|
|
215
|
-
cloned = deepCloneSchema(object, void 0, false);
|
|
216
|
-
} catch (error) {
|
|
217
|
-
console.warn("[Elysia] schema snapshot failed; schema kept by reference:", error);
|
|
218
|
-
return schema;
|
|
219
|
-
} finally {
|
|
220
|
-
freezeClones = false;
|
|
221
|
-
}
|
|
206
|
+
const cloned = cloneOrWarn(object, true);
|
|
207
|
+
if (cloned === void 0) return schema;
|
|
222
208
|
hookSnapshots.set(object, cloned);
|
|
223
209
|
produced.add(cloned);
|
|
224
210
|
if (key !== void 0) {
|
|
@@ -231,9 +217,34 @@ function snapshotSlots(target, intern) {
|
|
|
231
217
|
for (const slot of schemaSlots) if (target[slot] != null) target[slot] = internSchema(target[slot], intern);
|
|
232
218
|
const response = target.response;
|
|
233
219
|
if (response != null) if (typeof response === "object" && !("~standard" in response) && isStatusMap(response)) {
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
220
|
+
let next = {};
|
|
221
|
+
const state = { bail: false };
|
|
222
|
+
let key = "M";
|
|
223
|
+
for (const status in response) {
|
|
224
|
+
const schema = internSchema(response[status], intern);
|
|
225
|
+
Object.defineProperty(next, status, {
|
|
226
|
+
value: schema,
|
|
227
|
+
enumerable: true
|
|
228
|
+
});
|
|
229
|
+
key += status.length + ":" + status + byRefKey(schema, state);
|
|
230
|
+
}
|
|
231
|
+
if (key === "M") target.response = next;
|
|
232
|
+
else {
|
|
233
|
+
if (intern && !state.bail) {
|
|
234
|
+
const shared = interned.get(key);
|
|
235
|
+
if (shared === void 0) {
|
|
236
|
+
if (interned.size >= INTERN_LIMIT) evictOldestHalf(interned);
|
|
237
|
+
interned.set(key, next);
|
|
238
|
+
} else {
|
|
239
|
+
if (interned.size >= INTERN_LIMIT) {
|
|
240
|
+
interned.delete(key);
|
|
241
|
+
interned.set(key, shared);
|
|
242
|
+
}
|
|
243
|
+
next = shared;
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
target.response = Object.freeze(next);
|
|
247
|
+
}
|
|
237
248
|
} else target.response = internSchema(response, intern);
|
|
238
249
|
}
|
|
239
250
|
function isStatusMap(response) {
|
|
@@ -241,18 +252,12 @@ function isStatusMap(response) {
|
|
|
241
252
|
for (const key in response) if (!Number.isInteger(Number(key))) return false;
|
|
242
253
|
return true;
|
|
243
254
|
}
|
|
255
|
+
const hasSlot = (target) => schemaSlots.some((slot) => target[slot] != null) || target.response != null;
|
|
244
256
|
function snapshotHookSchemas(hook) {
|
|
245
257
|
if (!hook) return hook;
|
|
246
|
-
|
|
247
|
-
if (schemaSlots.some((slot) => hook[slot] != null) || hook.response != null) needsCopy = true;
|
|
258
|
+
const needsCopy = hasSlot(hook);
|
|
248
259
|
const schemas = hook.schemas;
|
|
249
|
-
if (!needsCopy && Array.isArray(schemas))
|
|
250
|
-
for (const entry of schemas) if (entry && (schemaSlots.some((slot) => entry[slot] != null) || entry.response != null)) {
|
|
251
|
-
needsCopy = true;
|
|
252
|
-
break;
|
|
253
|
-
}
|
|
254
|
-
}
|
|
255
|
-
if (!needsCopy) return hook;
|
|
260
|
+
if (!needsCopy && !(Array.isArray(schemas) && schemas.some((e) => e && hasSlot(e)))) return hook;
|
|
256
261
|
const intern = !env.ELYSIA_AOT_BUILD;
|
|
257
262
|
const copy = Object.assign(Object.create(Object.getPrototypeOf(hook)), hook);
|
|
258
263
|
snapshotSlots(copy, intern);
|
package/dist/sucrose.d.ts
CHANGED
|
@@ -11,64 +11,15 @@ declare namespace Sucrose {
|
|
|
11
11
|
route: boolean;
|
|
12
12
|
afterResponse?: boolean;
|
|
13
13
|
}
|
|
14
|
-
type LifeCycle = Partial<
|
|
14
|
+
type LifeCycle = Partial<AppHook>;
|
|
15
15
|
}
|
|
16
|
+
declare function clearSucroseCache(): void;
|
|
17
|
+
declare const mergeInference: (a: Sucrose.Inference, b: Sucrose.Inference) => Sucrose.Inference;
|
|
16
18
|
/**
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
* @example
|
|
20
|
-
* ```typescript
|
|
21
|
-
* separateFunction('async ({ hello }) => { return hello }') // => ['({ hello })', '{ return hello }']
|
|
22
|
-
* ```
|
|
23
|
-
*/
|
|
24
|
-
declare function separateFunction(code: string): [string, string];
|
|
25
|
-
/**
|
|
26
|
-
* Get range between bracket pair
|
|
27
|
-
*
|
|
28
|
-
* @example
|
|
29
|
-
* ```typescript
|
|
30
|
-
* bracketPairRange('hello: { world: { a } }, elysia') // [6, 20]
|
|
31
|
-
* ```
|
|
32
|
-
*/
|
|
33
|
-
declare function bracketPairRange(parameter: string): [number, number];
|
|
34
|
-
/**
|
|
35
|
-
* Similar to `bracketPairRange` but in reverse order
|
|
36
|
-
* Get range between bracket pair from end to beginning
|
|
37
|
-
*
|
|
38
|
-
* @example
|
|
39
|
-
* ```typescript
|
|
40
|
-
* bracketPairRange('hello: { world: { a } }, elysia') // [6, 20]
|
|
41
|
-
* ```
|
|
42
|
-
*/
|
|
43
|
-
declare function bracketPairRangeReverse(parameter: string): [number, number];
|
|
44
|
-
declare function removeColonAlias(parameter: string): string;
|
|
45
|
-
/**
|
|
46
|
-
* Retrieve only root parameters of a function
|
|
47
|
-
*
|
|
48
|
-
* @example
|
|
49
|
-
* ```typescript
|
|
50
|
-
* retrieveRootParameters('({ hello: { world: { a } }, elysia })') // => {
|
|
51
|
-
* parameters: ['hello', 'elysia'],
|
|
52
|
-
* hasParenthesis: true
|
|
53
|
-
* }
|
|
54
|
-
* ```
|
|
55
|
-
*/
|
|
56
|
-
declare function retrieveRootparameters(parameter: string): {
|
|
57
|
-
hasParenthesis: boolean;
|
|
58
|
-
parameters: Record<string, true>;
|
|
59
|
-
};
|
|
60
|
-
/**
|
|
61
|
-
* Find alias of variable from function body
|
|
62
|
-
*
|
|
63
|
-
* @example
|
|
64
|
-
* ```typescript
|
|
65
|
-
* findAlias('body', '{ const a = body, b = body }') // => ['a', 'b']
|
|
66
|
-
* ```
|
|
19
|
+
* @internal Which `channelOf`-mapped members of a function's first parameter
|
|
20
|
+
* the function may read, or `null` when any member may be read
|
|
67
21
|
*/
|
|
68
|
-
declare function
|
|
69
|
-
declare function removeDefaultParameter(parameter: string): string;
|
|
70
|
-
declare function clearSucroseCache(delay?: number | null): void;
|
|
71
|
-
declare const mergeInference: (a: Sucrose.Inference, b: Sucrose.Inference) => Sucrose.Inference;
|
|
22
|
+
declare function inferParameterReads<K extends string>(source: string, channelOf: (value: string) => K | undefined, strict?: boolean): Set<K> | null;
|
|
72
23
|
declare function sucrose(handler: Handler | undefined, lifeCycle: Sucrose.LifeCycle | undefined): Sucrose.Inference;
|
|
73
24
|
//#endregion
|
|
74
|
-
export { Sucrose,
|
|
25
|
+
export { Sucrose, clearSucroseCache, inferParameterReads, mergeInference, sucrose };
|