elysia 2.0.0-beta.25 → 2.0.0-beta.26
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/bun/index.js +5 -2
- package/dist/adapter/bun/index.mjs +5 -2
- package/dist/base.d.ts +7 -3
- package/dist/base.js +15 -14
- package/dist/base.mjs +15 -14
- package/dist/compile/aot-capture.js +1 -1
- package/dist/compile/aot-capture.mjs +1 -1
- package/dist/compile/handler/jit.js +5 -3
- package/dist/compile/handler/jit.mjs +5 -3
- package/dist/handler/fetch.js +2 -2
- package/dist/handler/fetch.mjs +2 -2
- package/dist/package.js +1 -1
- package/dist/package.mjs +1 -1
- package/dist/plugin/aot/core.js +8 -2
- package/dist/plugin/aot/core.mjs +8 -2
- package/dist/type/bridge-live.d.ts +1 -1
- package/dist/type/bridge-live.js +1 -1
- package/dist/type/bridge-live.mjs +1 -1
- package/dist/type/bridge.d.ts +1 -1
- package/dist/type/typebox-value-live.d.ts +2 -2
- package/dist/type/typebox-value-live.js +2 -2
- package/dist/type/typebox-value-live.mjs +2 -2
- package/dist/type/typebox-value-ops.d.ts +2 -2
- package/dist/type/typebox-value-ops.js +2 -2
- package/dist/type/typebox-value-ops.mjs +2 -2
- package/dist/type/typebox-value.d.ts +6 -6
- package/package.json +1 -1
|
@@ -105,7 +105,10 @@ function isNativePath(path) {
|
|
|
105
105
|
function collectHTMLBundleRoutes(app, handoff, routes) {
|
|
106
106
|
let dynamic;
|
|
107
107
|
let bundles;
|
|
108
|
-
|
|
108
|
+
const table = app["~generation"]?.routeTable;
|
|
109
|
+
if (table && !table.handler.some((h, i) => isNativeStaticMethod(table.method[i]) && require_utils.isHTMLBundle(h))) return routes;
|
|
110
|
+
const declared = table ? table.method.map((_, i) => require_route_table.routeRow(table, i)) : app["~routes"];
|
|
111
|
+
for (const route of declared) {
|
|
109
112
|
const [method, path, handler] = route;
|
|
110
113
|
if (!isNativeStaticMethod(method) || !require_utils.isHTMLBundle(handler)) continue;
|
|
111
114
|
if (path.indexOf(":") !== -1 || path.indexOf("*") !== -1) {
|
|
@@ -122,7 +125,7 @@ function collectHTMLBundleRoutes(app, handoff, routes) {
|
|
|
122
125
|
if (!dynamic) return routes;
|
|
123
126
|
const strictPath = app["~config"]?.strictPath === true;
|
|
124
127
|
const handoffs = [];
|
|
125
|
-
for (const [method, path, handler] of
|
|
128
|
+
for (const [method, path, handler] of declared) {
|
|
126
129
|
if (require_utils.isHTMLBundle(handler)) continue;
|
|
127
130
|
const targets = method === "*" ? dynamic : dynamic.has(method) ? [method] : void 0;
|
|
128
131
|
if (!targets) continue;
|
|
@@ -105,7 +105,10 @@ function isNativePath(path) {
|
|
|
105
105
|
function collectHTMLBundleRoutes(app, handoff, routes) {
|
|
106
106
|
let dynamic;
|
|
107
107
|
let bundles;
|
|
108
|
-
|
|
108
|
+
const table = app["~generation"]?.routeTable;
|
|
109
|
+
if (table && !table.handler.some((h, i) => isNativeStaticMethod(table.method[i]) && isHTMLBundle(h))) return routes;
|
|
110
|
+
const declared = table ? table.method.map((_, i) => routeRow(table, i)) : app["~routes"];
|
|
111
|
+
for (const route of declared) {
|
|
109
112
|
const [method, path, handler] = route;
|
|
110
113
|
if (!isNativeStaticMethod(method) || !isHTMLBundle(handler)) continue;
|
|
111
114
|
if (path.indexOf(":") !== -1 || path.indexOf("*") !== -1) {
|
|
@@ -122,7 +125,7 @@ function collectHTMLBundleRoutes(app, handoff, routes) {
|
|
|
122
125
|
if (!dynamic) return routes;
|
|
123
126
|
const strictPath = app["~config"]?.strictPath === true;
|
|
124
127
|
const handoffs = [];
|
|
125
|
-
for (const [method, path, handler] of
|
|
128
|
+
for (const [method, path, handler] of declared) {
|
|
126
129
|
if (isHTMLBundle(handler)) continue;
|
|
127
130
|
const targets = method === "*" ? dynamic : dynamic.has(method) ? [method] : void 0;
|
|
128
131
|
if (!targets) continue;
|
package/dist/base.d.ts
CHANGED
|
@@ -84,8 +84,11 @@ declare class Elysia<const in out BasePath extends string = '', const in out Sco
|
|
|
84
84
|
'~router'?: Memoirist<CompiledHandler | number>;
|
|
85
85
|
'~map'?: {
|
|
86
86
|
[method: string]: {
|
|
87
|
-
[path: string]: CompiledHandler;
|
|
87
|
+
[path: string]: CompiledHandler | number;
|
|
88
88
|
} | undefined;
|
|
89
|
+
WS?: {
|
|
90
|
+
[path: string]: CompiledHandler;
|
|
91
|
+
};
|
|
89
92
|
};
|
|
90
93
|
'~routeTable'?: RouteTable;
|
|
91
94
|
'~hasWS'?: boolean;
|
|
@@ -102,8 +105,9 @@ declare class Elysia<const in out BasePath extends string = '', const in out Sco
|
|
|
102
105
|
constructor(config?: ElysiaConfig<BasePath, Scope>);
|
|
103
106
|
/**
|
|
104
107
|
* Every registered route with its merged hooks.
|
|
105
|
-
* Development shares a frozen cache.
|
|
106
|
-
*
|
|
108
|
+
* Development shares a frozen cache.
|
|
109
|
+
* Production rebuilds the list on every read
|
|
110
|
+
* so its metadata can be released after startup.
|
|
107
111
|
*/
|
|
108
112
|
get routes(): PublicRoute[];
|
|
109
113
|
/**
|
package/dist/base.js
CHANGED
|
@@ -224,8 +224,9 @@ var Elysia = class Elysia {
|
|
|
224
224
|
}
|
|
225
225
|
/**
|
|
226
226
|
* Every registered route with its merged hooks.
|
|
227
|
-
* Development shares a frozen cache.
|
|
228
|
-
*
|
|
227
|
+
* Development shares a frozen cache.
|
|
228
|
+
* Production rebuilds the list on every read
|
|
229
|
+
* so its metadata can be released after startup.
|
|
229
230
|
*/
|
|
230
231
|
get routes() {
|
|
231
232
|
const generation = this["~generation"];
|
|
@@ -1517,7 +1518,7 @@ var Elysia = class Elysia {
|
|
|
1517
1518
|
const satisfied = (table.flags[i] & require_route_table.RouteFlag.JITSatisfied) !== 0;
|
|
1518
1519
|
table.flags[i] &= ~(require_route_table.RouteFlag.JITCold | require_route_table.RouteFlag.JITSatisfied);
|
|
1519
1520
|
const flags = table.flags[i];
|
|
1520
|
-
if (satisfied || (flags & (require_route_table.RouteFlag.WS | require_route_table.RouteFlag.ExactDuplicate)) !== 0 || compiled?.[i] !== void 0) continue;
|
|
1521
|
+
if (satisfied || (flags & (require_route_table.RouteFlag.WS | require_route_table.RouteFlag.ExactDuplicate)) !== 0 || compiled?.[i] !== void 0 || require_utils.isHTMLBundle(table.handler[i])) continue;
|
|
1521
1522
|
table.flags[i] |= require_route_table.RouteFlag.JITCold;
|
|
1522
1523
|
cold++;
|
|
1523
1524
|
}
|
|
@@ -1526,8 +1527,8 @@ var Elysia = class Elysia {
|
|
|
1526
1527
|
}
|
|
1527
1528
|
require_compile_handler_index.clearHandlerAnalysisCaches(this);
|
|
1528
1529
|
require_utils.clearFlattenChainMemo(this);
|
|
1529
|
-
if (!this["~ext"]?.macro && !this["~scopeChildren"]) this.declaredRoutes = void 0;
|
|
1530
1530
|
}
|
|
1531
|
+
if (!this["~ext"]?.macro && !this["~scopeChildren"] && !require_compile_aot.Capture.isAotBuildEnv()) this.declaredRoutes = void 0;
|
|
1531
1532
|
const ext = this["~ext"];
|
|
1532
1533
|
if (ext?.setup) extCallbackIndexes.delete(ext.setup);
|
|
1533
1534
|
if (ext?.cleanup) extCallbackIndexes.delete(ext.cleanup);
|
|
@@ -1623,32 +1624,32 @@ var Elysia = class Elysia {
|
|
|
1623
1624
|
}
|
|
1624
1625
|
continue;
|
|
1625
1626
|
}
|
|
1627
|
+
const lazy = !precompile && !this.compiled?.[i];
|
|
1628
|
+
if (lazy) {
|
|
1629
|
+
this.compiled ??= new Array(length);
|
|
1630
|
+
this.jitTable = table;
|
|
1631
|
+
}
|
|
1626
1632
|
const isDynamic = (routeFlags & require_route_table.RouteFlag.Dynamic) !== 0;
|
|
1627
1633
|
const needsEncode = (routeFlags & require_route_table.RouteFlag.Encode) !== 0;
|
|
1628
1634
|
const registerLoose = isLoose && canRegisterLoose(routePath, isDynamic);
|
|
1629
1635
|
if (!isDynamic && !needsEncode && !registerLoose) {
|
|
1630
1636
|
const map = methods[routeMethod] ??= require_utils.nullObject();
|
|
1631
|
-
map[routePath] = this.handler(i, precompile, void 0, void 0, table);
|
|
1637
|
+
map[routePath] = lazy ? ~i : this.handler(i, precompile, void 0, void 0, table);
|
|
1632
1638
|
continue;
|
|
1633
1639
|
}
|
|
1634
1640
|
const paths = expandPaths(routePath, needsEncode, registerLoose, registerLoose ? explicitPaths?.get(routeMethod) : void 0);
|
|
1635
1641
|
if (isDynamic) {
|
|
1636
1642
|
if (require_utils.isHTMLBundle(table.handler[i])) continue;
|
|
1637
1643
|
const router = this["~router"] ??= new memoirist.default({ loosePath: isLoose });
|
|
1638
|
-
|
|
1639
|
-
if (precompile || this.compiled?.[i]) store = this.handler(i, precompile, void 0, void 0, table);
|
|
1640
|
-
else {
|
|
1641
|
-
this.compiled ??= new Array(length);
|
|
1642
|
-
this.jitTable = table;
|
|
1643
|
-
store = i;
|
|
1644
|
-
}
|
|
1644
|
+
const store = lazy ? i : this.handler(i, precompile, void 0, void 0, table);
|
|
1645
1645
|
for (let p = 0; p < paths.length; p++) router.add(routeMethod, paths[p], store);
|
|
1646
1646
|
} else {
|
|
1647
1647
|
const map = methods[routeMethod] ??= require_utils.nullObject();
|
|
1648
|
-
|
|
1648
|
+
if (lazy) (this.jitAliases ??= [])[i] = {
|
|
1649
1649
|
method: routeMethod,
|
|
1650
1650
|
paths
|
|
1651
|
-
}
|
|
1651
|
+
};
|
|
1652
|
+
const handler = lazy ? ~i : this.handler(i, precompile, void 0, void 0, table);
|
|
1652
1653
|
for (let p = 0; p < paths.length; p++) map[paths[p]] = handler;
|
|
1653
1654
|
}
|
|
1654
1655
|
}
|
package/dist/base.mjs
CHANGED
|
@@ -222,8 +222,9 @@ var Elysia = class Elysia {
|
|
|
222
222
|
}
|
|
223
223
|
/**
|
|
224
224
|
* Every registered route with its merged hooks.
|
|
225
|
-
* Development shares a frozen cache.
|
|
226
|
-
*
|
|
225
|
+
* Development shares a frozen cache.
|
|
226
|
+
* Production rebuilds the list on every read
|
|
227
|
+
* so its metadata can be released after startup.
|
|
227
228
|
*/
|
|
228
229
|
get routes() {
|
|
229
230
|
const generation = this["~generation"];
|
|
@@ -1515,7 +1516,7 @@ var Elysia = class Elysia {
|
|
|
1515
1516
|
const satisfied = (table.flags[i] & RouteFlag.JITSatisfied) !== 0;
|
|
1516
1517
|
table.flags[i] &= ~(RouteFlag.JITCold | RouteFlag.JITSatisfied);
|
|
1517
1518
|
const flags = table.flags[i];
|
|
1518
|
-
if (satisfied || (flags & (RouteFlag.WS | RouteFlag.ExactDuplicate)) !== 0 || compiled?.[i] !== void 0) continue;
|
|
1519
|
+
if (satisfied || (flags & (RouteFlag.WS | RouteFlag.ExactDuplicate)) !== 0 || compiled?.[i] !== void 0 || isHTMLBundle(table.handler[i])) continue;
|
|
1519
1520
|
table.flags[i] |= RouteFlag.JITCold;
|
|
1520
1521
|
cold++;
|
|
1521
1522
|
}
|
|
@@ -1524,8 +1525,8 @@ var Elysia = class Elysia {
|
|
|
1524
1525
|
}
|
|
1525
1526
|
clearHandlerAnalysisCaches(this);
|
|
1526
1527
|
clearFlattenChainMemo(this);
|
|
1527
|
-
if (!this["~ext"]?.macro && !this["~scopeChildren"]) this.declaredRoutes = void 0;
|
|
1528
1528
|
}
|
|
1529
|
+
if (!this["~ext"]?.macro && !this["~scopeChildren"] && !Capture.isAotBuildEnv()) this.declaredRoutes = void 0;
|
|
1529
1530
|
const ext = this["~ext"];
|
|
1530
1531
|
if (ext?.setup) extCallbackIndexes.delete(ext.setup);
|
|
1531
1532
|
if (ext?.cleanup) extCallbackIndexes.delete(ext.cleanup);
|
|
@@ -1621,32 +1622,32 @@ var Elysia = class Elysia {
|
|
|
1621
1622
|
}
|
|
1622
1623
|
continue;
|
|
1623
1624
|
}
|
|
1625
|
+
const lazy = !precompile && !this.compiled?.[i];
|
|
1626
|
+
if (lazy) {
|
|
1627
|
+
this.compiled ??= new Array(length);
|
|
1628
|
+
this.jitTable = table;
|
|
1629
|
+
}
|
|
1624
1630
|
const isDynamic = (routeFlags & RouteFlag.Dynamic) !== 0;
|
|
1625
1631
|
const needsEncode = (routeFlags & RouteFlag.Encode) !== 0;
|
|
1626
1632
|
const registerLoose = isLoose && canRegisterLoose(routePath, isDynamic);
|
|
1627
1633
|
if (!isDynamic && !needsEncode && !registerLoose) {
|
|
1628
1634
|
const map = methods[routeMethod] ??= nullObject();
|
|
1629
|
-
map[routePath] = this.handler(i, precompile, void 0, void 0, table);
|
|
1635
|
+
map[routePath] = lazy ? ~i : this.handler(i, precompile, void 0, void 0, table);
|
|
1630
1636
|
continue;
|
|
1631
1637
|
}
|
|
1632
1638
|
const paths = expandPaths(routePath, needsEncode, registerLoose, registerLoose ? explicitPaths?.get(routeMethod) : void 0);
|
|
1633
1639
|
if (isDynamic) {
|
|
1634
1640
|
if (isHTMLBundle(table.handler[i])) continue;
|
|
1635
1641
|
const router = this["~router"] ??= new Memoirist({ loosePath: isLoose });
|
|
1636
|
-
|
|
1637
|
-
if (precompile || this.compiled?.[i]) store = this.handler(i, precompile, void 0, void 0, table);
|
|
1638
|
-
else {
|
|
1639
|
-
this.compiled ??= new Array(length);
|
|
1640
|
-
this.jitTable = table;
|
|
1641
|
-
store = i;
|
|
1642
|
-
}
|
|
1642
|
+
const store = lazy ? i : this.handler(i, precompile, void 0, void 0, table);
|
|
1643
1643
|
for (let p = 0; p < paths.length; p++) router.add(routeMethod, paths[p], store);
|
|
1644
1644
|
} else {
|
|
1645
1645
|
const map = methods[routeMethod] ??= nullObject();
|
|
1646
|
-
|
|
1646
|
+
if (lazy) (this.jitAliases ??= [])[i] = {
|
|
1647
1647
|
method: routeMethod,
|
|
1648
1648
|
paths
|
|
1649
|
-
}
|
|
1649
|
+
};
|
|
1650
|
+
const handler = lazy ? ~i : this.handler(i, precompile, void 0, void 0, table);
|
|
1650
1651
|
for (let p = 0; p < paths.length; p++) map[paths[p]] = handler;
|
|
1651
1652
|
}
|
|
1652
1653
|
}
|
|
@@ -13,8 +13,8 @@ const require_type_validator_frozen_check = require('../type/validator/frozen-ch
|
|
|
13
13
|
const require_type_validator_custom_error = require('../type/validator/custom-error.js');
|
|
14
14
|
const require_type_validator_exact_mirror = require('../type/validator/exact-mirror.js');
|
|
15
15
|
const require_type_validator_string_codec_aot = require('../type/validator/string-codec-aot.js');
|
|
16
|
-
let typebox_value = require("typebox/value");
|
|
17
16
|
let typebox_schema = require("typebox/schema");
|
|
17
|
+
let typebox_value = require("typebox/value");
|
|
18
18
|
|
|
19
19
|
//#region src/compile/aot-capture.ts
|
|
20
20
|
function emptyContainers(node, depth) {
|
|
@@ -12,8 +12,8 @@ import { buildFrozenCheck } from "../type/validator/frozen-check.mjs";
|
|
|
12
12
|
import { captureCustomErrors } from "../type/validator/custom-error.mjs";
|
|
13
13
|
import { getExactMirror } from "../type/validator/exact-mirror.mjs";
|
|
14
14
|
import { captureStringCodecEntries, compileWithBuild } from "../type/validator/string-codec-aot.mjs";
|
|
15
|
-
import { Default } from "typebox/value";
|
|
16
15
|
import { Build, Compile } from "typebox/schema";
|
|
16
|
+
import { Default } from "typebox/value";
|
|
17
17
|
|
|
18
18
|
//#region src/compile/aot-capture.ts
|
|
19
19
|
function emptyContainers(node, depth) {
|
|
@@ -562,9 +562,11 @@ function compileHandlerJit(options, tailPass) {
|
|
|
562
562
|
], abortChainGuard(), require_compile_handler_utils.asyncTail(asyncMode)) + endTrace("error") + (hasDeriveDispose ? schedule + abortCatch : abortCatch + schedule) + `return _efb(e,c)\n`;
|
|
563
563
|
} else body += endTrace("error") + freThenSchedule("e");
|
|
564
564
|
const hookThrew = `catch(_ee){${freThenSchedule("_ee").trimEnd()}}}\n`;
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
565
|
+
const syncFirst = typeof asyncMode === "object" && !asyncMode.async;
|
|
566
|
+
if (syncErrorHook || syncFirst) {
|
|
567
|
+
const live = syncFirst ? asyncMode.live : "";
|
|
568
|
+
factoryHelpers += `function _ce(e,c${live}){${abortOn ? "let _as\n" : ""}try{\n${body}}${hookThrew}`;
|
|
569
|
+
code += `}catch(e){return _ce(e,c${live})}\n`;
|
|
568
570
|
} else code += `}catch(e){try{\n${body}}${hookThrew}`;
|
|
569
571
|
} else code += catchSchedule ? `}catch(e){${freThenSchedule("e")}}\n` : `}catch(e){return fre(rt,c,e)}\n`;
|
|
570
572
|
if (tailPass) return code;
|
|
@@ -562,9 +562,11 @@ function compileHandlerJit(options, tailPass) {
|
|
|
562
562
|
], abortChainGuard(), asyncTail(asyncMode)) + endTrace("error") + (hasDeriveDispose ? schedule + abortCatch : abortCatch + schedule) + `return _efb(e,c)\n`;
|
|
563
563
|
} else body += endTrace("error") + freThenSchedule("e");
|
|
564
564
|
const hookThrew = `catch(_ee){${freThenSchedule("_ee").trimEnd()}}}\n`;
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
565
|
+
const syncFirst = typeof asyncMode === "object" && !asyncMode.async;
|
|
566
|
+
if (syncErrorHook || syncFirst) {
|
|
567
|
+
const live = syncFirst ? asyncMode.live : "";
|
|
568
|
+
factoryHelpers += `function _ce(e,c${live}){${abortOn ? "let _as\n" : ""}try{\n${body}}${hookThrew}`;
|
|
569
|
+
code += `}catch(e){return _ce(e,c${live})}\n`;
|
|
568
570
|
} else code += `}catch(e){try{\n${body}}${hookThrew}`;
|
|
569
571
|
} else code += catchSchedule ? `}catch(e){${freThenSchedule("e")}}\n` : `}catch(e){return fre(rt,c,e)}\n`;
|
|
570
572
|
if (tailPass) return code;
|
package/dist/handler/fetch.js
CHANGED
|
@@ -100,12 +100,12 @@ function findRoute(context, request, map, router, onNotFound, handleError, after
|
|
|
100
100
|
}
|
|
101
101
|
} else handler = map["*"]?.[path];
|
|
102
102
|
} else handler = methodMap?.[context.path] || map["*"]?.[path];
|
|
103
|
-
if (handler) return dispatchResult(handler(context), context, handleError, afterResponse);
|
|
103
|
+
if (handler) return dispatchResult(typeof handler === "number" ? app["~dispatch"](~handler, context) : handler(context), context, handleError, afterResponse);
|
|
104
104
|
const found = router?.find(method, path) ?? router?.find("*", path);
|
|
105
105
|
if (found) {
|
|
106
106
|
context.params = path.indexOf("%") === -1 ? found.params : decodeParams(found.params);
|
|
107
107
|
const store = found.store;
|
|
108
|
-
const dynamic = typeof store === "number" ?
|
|
108
|
+
const dynamic = typeof store === "number" ? void 0 : store;
|
|
109
109
|
return dispatchResult(dynamic ? dynamic(context) : app["~dispatch"](store, context), context, handleError, afterResponse);
|
|
110
110
|
}
|
|
111
111
|
return onNotFound(context);
|
package/dist/handler/fetch.mjs
CHANGED
|
@@ -98,12 +98,12 @@ function findRoute(context, request, map, router, onNotFound, handleError, after
|
|
|
98
98
|
}
|
|
99
99
|
} else handler = map["*"]?.[path];
|
|
100
100
|
} else handler = methodMap?.[context.path] || map["*"]?.[path];
|
|
101
|
-
if (handler) return dispatchResult(handler(context), context, handleError, afterResponse);
|
|
101
|
+
if (handler) return dispatchResult(typeof handler === "number" ? app["~dispatch"](~handler, context) : handler(context), context, handleError, afterResponse);
|
|
102
102
|
const found = router?.find(method, path) ?? router?.find("*", path);
|
|
103
103
|
if (found) {
|
|
104
104
|
context.params = path.indexOf("%") === -1 ? found.params : decodeParams(found.params);
|
|
105
105
|
const store = found.store;
|
|
106
|
-
const dynamic = typeof store === "number" ?
|
|
106
|
+
const dynamic = typeof store === "number" ? void 0 : store;
|
|
107
107
|
return dispatchResult(dynamic ? dynamic(context) : app["~dispatch"](store, context), context, handleError, afterResponse);
|
|
108
108
|
}
|
|
109
109
|
return onNotFound(context);
|
package/dist/package.js
CHANGED
package/dist/package.mjs
CHANGED
package/dist/plugin/aot/core.js
CHANGED
|
@@ -463,8 +463,14 @@ async function generateCompiledArtifacts(file, options, moduleCondition = resolv
|
|
|
463
463
|
if (_importedEntries.has(entryReal)) return generateCompiledArtifactsIsolated(file, options, moduleCondition);
|
|
464
464
|
_importedEntries.add(entryReal);
|
|
465
465
|
const mod = await import(entry);
|
|
466
|
-
const
|
|
467
|
-
|
|
466
|
+
const isApp = (value) => typeof value?.compile === "function";
|
|
467
|
+
let app = isApp(mod.app) ? mod.app : mod.default;
|
|
468
|
+
if (!isApp(app)) {
|
|
469
|
+
const names = Object.keys(mod).filter((name) => isApp(mod[name]));
|
|
470
|
+
if (new Set(names.map((name) => mod[name])).size > 1) throw new Error(`[elysia-aot] "${entry}" exports multiple Elysia apps (${names.join(", ")}). Export the one to compile as \`app\` or default`);
|
|
471
|
+
app = names[0] ? mod[names[0]] : void 0;
|
|
472
|
+
}
|
|
473
|
+
if (!isApp(app)) throw new Error(`[elysia-aot] "${entry}" must export an Elysia app`);
|
|
468
474
|
const typedApp = app;
|
|
469
475
|
assertNoMount(typedApp, entry);
|
|
470
476
|
const sourceOptions = {
|
package/dist/plugin/aot/core.mjs
CHANGED
|
@@ -461,8 +461,14 @@ async function generateCompiledArtifacts(file, options, moduleCondition = resolv
|
|
|
461
461
|
if (_importedEntries.has(entryReal)) return generateCompiledArtifactsIsolated(file, options, moduleCondition);
|
|
462
462
|
_importedEntries.add(entryReal);
|
|
463
463
|
const mod = await import(entry);
|
|
464
|
-
const
|
|
465
|
-
|
|
464
|
+
const isApp = (value) => typeof value?.compile === "function";
|
|
465
|
+
let app = isApp(mod.app) ? mod.app : mod.default;
|
|
466
|
+
if (!isApp(app)) {
|
|
467
|
+
const names = Object.keys(mod).filter((name) => isApp(mod[name]));
|
|
468
|
+
if (new Set(names.map((name) => mod[name])).size > 1) throw new Error(`[elysia-aot] "${entry}" exports multiple Elysia apps (${names.join(", ")}). Export the one to compile as \`app\` or default`);
|
|
469
|
+
app = names[0] ? mod[names[0]] : void 0;
|
|
470
|
+
}
|
|
471
|
+
if (!isApp(app)) throw new Error(`[elysia-aot] "${entry}" must export an Elysia app`);
|
|
466
472
|
const typedApp = app;
|
|
467
473
|
assertNoMount(typedApp, entry);
|
|
468
474
|
const sourceOptions = {
|
|
@@ -5,8 +5,8 @@ import { useTypebox as useTypebox$1 } from "./bridge.js";
|
|
|
5
5
|
import { TypeBoxValidatorCache, mayHaveFileType } from "./validator/validator-cache.js";
|
|
6
6
|
import { TypeBoxValidator } from "./validator/index.js";
|
|
7
7
|
import { Ref } from "typebox/type";
|
|
8
|
-
import { Compile } from "typebox/compile";
|
|
9
8
|
import { Check, Clone, Create, Decode, HasCodec } from "typebox/value";
|
|
9
|
+
import { Compile } from "typebox/compile";
|
|
10
10
|
|
|
11
11
|
//#region src/type/bridge-live.d.ts
|
|
12
12
|
declare function useTypebox(_mod?: Parameters<typeof useTypebox$1>[0]): void;
|
package/dist/type/bridge-live.js
CHANGED
|
@@ -6,8 +6,8 @@ const require_type_validator_validator_cache = require('./validator/validator-ca
|
|
|
6
6
|
const require_type_validator_index = require('./validator/index.js');
|
|
7
7
|
const require_type_elysia_intersect = require('./elysia/intersect.js');
|
|
8
8
|
let typebox_type = require("typebox/type");
|
|
9
|
-
let typebox_compile = require("typebox/compile");
|
|
10
9
|
let typebox_value = require("typebox/value");
|
|
10
|
+
let typebox_compile = require("typebox/compile");
|
|
11
11
|
let typebox_system = require("typebox/system");
|
|
12
12
|
|
|
13
13
|
//#region src/type/bridge-live.ts
|
|
@@ -5,8 +5,8 @@ import { TypeBoxValidatorCache, mayHaveFileType } from "./validator/validator-ca
|
|
|
5
5
|
import { TypeBoxValidator } from "./validator/index.mjs";
|
|
6
6
|
import { Intersect } from "./elysia/intersect.mjs";
|
|
7
7
|
import { Ref } from "typebox/type";
|
|
8
|
-
import { Compile } from "typebox/compile";
|
|
9
8
|
import { Check, Clone, Create, Decode, HasCodec } from "typebox/value";
|
|
9
|
+
import { Compile } from "typebox/compile";
|
|
10
10
|
import { Settings } from "typebox/system";
|
|
11
11
|
|
|
12
12
|
//#region src/type/bridge-live.ts
|
package/dist/type/bridge.d.ts
CHANGED
|
@@ -4,8 +4,8 @@ import { hasTypes as hasTypes$1 } from "./utils.js";
|
|
|
4
4
|
import { TypeBoxValidatorCache as TypeBoxValidatorCache$1, mayHaveFileType as mayHaveFileType$1 } from "./validator/validator-cache.js";
|
|
5
5
|
import { TypeBoxValidator as TypeBoxValidator$1 } from "./validator/index.js";
|
|
6
6
|
import { Ref as Ref$1, TAny, TSchema } from "typebox/type";
|
|
7
|
-
import { Compile as Compile$1 } from "typebox/compile";
|
|
8
7
|
import { Check as Check$1, Clone as Clone$1, Create as Create$1, Decode as Decode$2, HasCodec as HasCodec$1 } from "typebox/value";
|
|
8
|
+
import { Compile as Compile$1 } from "typebox/compile";
|
|
9
9
|
|
|
10
10
|
//#region src/type/bridge.d.ts
|
|
11
11
|
interface TypeboxModule {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { TypeboxNamespaces } from "./typebox-value.js";
|
|
2
|
-
import { Compile } from "typebox/compile";
|
|
3
|
-
import { Check, Clean, Clone, Create, Decode, DecodeUnsafe, Default, Encode, EncodeUnsafe, Errors, HasCodec } from "typebox/value";
|
|
4
2
|
import { Build, Compile as SchemaCompile } from "typebox/schema";
|
|
3
|
+
import { Check, Clean, Clone, Create, Decode, DecodeUnsafe, Default, Encode, EncodeUnsafe, Errors, HasCodec } from "typebox/value";
|
|
4
|
+
import { Compile } from "typebox/compile";
|
|
5
5
|
|
|
6
6
|
//#region src/type/typebox-value-live.d.ts
|
|
7
7
|
declare function injectTypebox(_typebox?: TypeboxNamespaces): void;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
2
|
const require_runtime = require('../_virtual/_rolldown/runtime.js');
|
|
3
|
-
let
|
|
3
|
+
let typebox_schema = require("typebox/schema");
|
|
4
4
|
let typebox_value = require("typebox/value");
|
|
5
|
+
let typebox_compile = require("typebox/compile");
|
|
5
6
|
let typebox_system = require("typebox/system");
|
|
6
|
-
let typebox_schema = require("typebox/schema");
|
|
7
7
|
|
|
8
8
|
//#region src/type/typebox-value-live.ts
|
|
9
9
|
typebox_system.Settings.Set({ unionPrioritySort: false });
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import { Compile } from "typebox/
|
|
2
|
+
import { Build, Compile as SchemaCompile } from "typebox/schema";
|
|
3
3
|
import { Check, Clean, Clone, Create, Decode, DecodeUnsafe, Default, Encode, EncodeUnsafe, Errors, HasCodec } from "typebox/value";
|
|
4
|
+
import { Compile } from "typebox/compile";
|
|
4
5
|
import { Settings } from "typebox/system";
|
|
5
|
-
import { Build, Compile as SchemaCompile } from "typebox/schema";
|
|
6
6
|
|
|
7
7
|
//#region src/type/typebox-value-live.ts
|
|
8
8
|
Settings.Set({ unionPrioritySort: false });
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Compile } from "typebox/compile";
|
|
2
|
-
import { Check, Clean, Clone, Create, Decode, DecodeUnsafe, Default, Encode, EncodeUnsafe, Errors, HasCodec } from "typebox/value";
|
|
3
1
|
import { Build, Compile as SchemaCompile } from "typebox/schema";
|
|
2
|
+
import { Check, Clean, Clone, Create, Decode, DecodeUnsafe, Default, Encode, EncodeUnsafe, Errors, HasCodec } from "typebox/value";
|
|
3
|
+
import { Compile } from "typebox/compile";
|
|
4
4
|
export { Build, Check, Clean, Clone, Compile, Create, Decode, DecodeUnsafe, Default, Encode, EncodeUnsafe, Errors, HasCodec, SchemaCompile };
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
2
|
const require_runtime = require('../_virtual/_rolldown/runtime.js');
|
|
3
|
-
let typebox_compile = require("typebox/compile");
|
|
4
|
-
let typebox_value = require("typebox/value");
|
|
5
3
|
let typebox_schema = require("typebox/schema");
|
|
4
|
+
let typebox_value = require("typebox/value");
|
|
5
|
+
let typebox_compile = require("typebox/compile");
|
|
6
6
|
|
|
7
7
|
Object.defineProperty(exports, 'Build', {
|
|
8
8
|
enumerable: true,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import { Compile } from "typebox/compile";
|
|
3
|
-
import { Check, Clean, Clone, Create, Decode, DecodeUnsafe, Default, Encode, EncodeUnsafe, Errors, HasCodec } from "typebox/value";
|
|
4
2
|
import { Build, Compile as SchemaCompile } from "typebox/schema";
|
|
3
|
+
import { Check, Clean, Clone, Create, Decode, DecodeUnsafe, Default, Encode, EncodeUnsafe, Errors, HasCodec } from "typebox/value";
|
|
4
|
+
import { Compile } from "typebox/compile";
|
|
5
5
|
|
|
6
6
|
export { Build, Check, Clean, Clone, Compile, Create, Decode, DecodeUnsafe, Default, Encode, EncodeUnsafe, Errors, HasCodec, SchemaCompile };
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import * as _$
|
|
2
|
-
import { Compile as Compile$1 } from "typebox/
|
|
1
|
+
import * as _$typebox_schema0 from "typebox/schema";
|
|
2
|
+
import { Build as Build$1, Compile as Compile$1 } from "typebox/schema";
|
|
3
3
|
import * as _$typebox_value0 from "typebox/value";
|
|
4
4
|
import { Check as Check$1, Clean as Clean$1, Clone as Clone$1, Create as Create$1, Decode as Decode$1, DecodeUnsafe as DecodeUnsafe$1, Default as Default$1, Encode as Encode$1, EncodeUnsafe as EncodeUnsafe$1, Errors as Errors$1, HasCodec as HasCodec$1 } from "typebox/value";
|
|
5
|
-
import * as _$
|
|
6
|
-
import {
|
|
5
|
+
import * as _$typebox_compile0 from "typebox/compile";
|
|
6
|
+
import { Compile as Compile$2 } from "typebox/compile";
|
|
7
7
|
|
|
8
8
|
//#region src/type/typebox-value.d.ts
|
|
9
9
|
interface TypeboxNamespaces {
|
|
@@ -27,9 +27,9 @@ declare let Encode: typeof Encode$1;
|
|
|
27
27
|
declare let EncodeUnsafe: typeof EncodeUnsafe$1;
|
|
28
28
|
declare let Errors: typeof Errors$1;
|
|
29
29
|
declare let HasCodec: typeof HasCodec$1;
|
|
30
|
-
declare let SchemaCompile: typeof Compile$
|
|
30
|
+
declare let SchemaCompile: typeof Compile$1;
|
|
31
31
|
declare let Build: typeof Build$1;
|
|
32
|
-
declare let Compile: typeof Compile$
|
|
32
|
+
declare let Compile: typeof Compile$2;
|
|
33
33
|
declare function injectTypebox(typebox: TypeboxNamespaces): void;
|
|
34
34
|
//#endregion
|
|
35
35
|
export { Build, Check, Clean, Clone, Compile, Create, Decode, DecodeUnsafe, Default, Encode, EncodeUnsafe, Errors, HasCodec, SchemaCompile, TypeboxNamespaces, injectTypebox, preloadTypebox, load as warmTypebox };
|