@teyik0/furin 0.4.0-alpha.2 → 0.5.0-alpha.1
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/build/compile-entry.d.ts +2 -1
- package/dist/build/compile-entry.ts +17 -13
- package/dist/build/elysia-aot.d.ts +9 -0
- package/dist/build/entry-template.d.ts +5 -1
- package/dist/build/entry-template.ts +24 -5
- package/dist/build/index.js +753 -453
- package/dist/build/server-app-entry.d.ts +12 -0
- package/dist/cache.d.ts +1 -0
- package/dist/cache.js +185 -0
- package/dist/cli/index.js +766 -466
- package/dist/client/internal/runtime-types.d.ts +8 -1
- package/dist/client/link.js +221 -11
- package/dist/client/sync.d.ts +1 -0
- package/dist/config.d.ts +22 -21
- package/dist/config.js +1 -1
- package/dist/define-route.d.ts +273 -1009
- package/dist/furin.d.ts +20 -5
- package/dist/furin.js +6222 -5383
- package/dist/plugin/routes.d.ts +6 -0
- package/dist/server/assets/production.d.ts +3 -0
- package/dist/server/auto-invalidate/plugin.d.ts +8 -24
- package/dist/server/auto-invalidate/runtime.d.ts +2 -2
- package/dist/server/cache/invalidation.d.ts +1 -1
- package/dist/server/cache/page-cache-state.d.ts +5 -0
- package/dist/server/cache/page-cache.d.ts +53 -0
- package/dist/server/cache/redis/index.d.ts +39 -0
- package/dist/server/cache/redis/index.js +396 -0
- package/dist/server/cache/redis/scripts.d.ts +6 -0
- package/dist/server/context-logger.d.ts +2 -2
- package/dist/server/dev/runtime.production.d.ts +1 -0
- package/dist/server/dev-page-plugin.d.ts +7 -0
- package/dist/server/evlog.d.ts +14 -0
- package/dist/server/internal.d.ts +6 -0
- package/dist/server/internal.js +2537 -0
- package/dist/server/render/not-found.d.ts +1 -1
- package/dist/server/render/ssg.d.ts +5 -0
- package/dist/server/render/static-params.d.ts +4 -0
- package/dist/server/router/defined-route.d.ts +1 -1
- package/dist/server/router/schemas.d.ts +1 -0
- package/dist/server/sync/index.js +794 -116
- package/dist/server/sync/plugin.d.ts +31 -158
- package/dist/server/sync/stream.d.ts +34 -49
- package/dist/shared/elysia-contract.d.ts +8 -14
- package/package.json +13 -7
- package/src/adapter/README.md +9 -2
- package/src/adapter/bun.ts +73 -27
- package/src/adapter/package.ts +6 -2
- package/src/adapter/runtime-build.ts +11 -4
- package/src/adapter/static.ts +8 -6
- package/src/adapter/vercel.ts +49 -30
- package/src/build/client.ts +18 -1
- package/src/build/compile-entry.ts +17 -13
- package/src/build/elysia-aot.ts +102 -0
- package/src/build/entry-template.ts +24 -5
- package/src/build/index.ts +0 -5
- package/src/build/production-instrumentation.ts +2 -2
- package/src/build/server-app-entry.ts +60 -0
- package/src/build/shared.ts +3 -1
- package/src/build/ssg-cache.ts +5 -10
- package/src/build/virtual-entry.ts +5 -4
- package/src/cache.ts +12 -0
- package/src/cli/config.ts +3 -3
- package/src/cli/index.ts +5 -2
- package/src/client/internal/runtime-types.ts +10 -1
- package/src/client/sync.ts +1 -0
- package/src/config.ts +3 -2
- package/src/define-route.ts +266 -128
- package/src/furin.ts +138 -149
- package/src/plugin/route-config-autofix.ts +11 -2
- package/src/plugin/routes.ts +85 -29
- package/src/server/assets/production.ts +99 -0
- package/src/server/auto-invalidate/plugin.ts +4 -4
- package/src/server/auto-invalidate/runtime.ts +74 -42
- package/src/server/browser-events/plugin.ts +6 -1
- package/src/server/cache/invalidation.ts +61 -20
- package/src/server/cache/page-cache-state.ts +22 -0
- package/src/server/cache/page-cache.ts +300 -0
- package/src/server/cache/redis/index.ts +350 -0
- package/src/server/cache/redis/scripts.ts +160 -0
- package/src/server/context-logger.ts +5 -5
- package/src/server/dev/runtime.production.ts +4 -0
- package/src/server/dev-page-plugin.ts +54 -10
- package/src/server/evlog.ts +99 -0
- package/src/server/internal.ts +7 -0
- package/src/server/render/isr.ts +480 -132
- package/src/server/render/loaders.ts +18 -12
- package/src/server/render/not-found.ts +4 -4
- package/src/server/render/ppr-document.ts +2 -2
- package/src/server/render/ppr-route.ts +193 -7
- package/src/server/render/ssg.ts +148 -4
- package/src/server/render/ssr.ts +4 -6
- package/src/server/render/static-params.ts +174 -0
- package/src/server/router/defined-route.ts +2 -1
- package/src/server/router/hmr.ts +2 -0
- package/src/server/router/plugin.ts +44 -35
- package/src/server/router/schema-merge.ts +1 -1
- package/src/server/router/schemas.ts +174 -61
- package/src/server/sync/plugin.ts +14 -10
- package/src/server/sync/response.ts +3 -3
- package/src/shared/elysia-contract.ts +23 -25
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { type BuildEntryOptions } from "./entry-template";
|
|
1
|
+
import { type BuildEntryOptions, type EntryAppContext } from "./entry-template";
|
|
2
2
|
import { type VirtualBuildEntry } from "./virtual-entry.ts";
|
|
3
|
+
export declare function prepareCompileEntryApps(options: BuildEntryOptions): EntryAppContext[];
|
|
3
4
|
/**
|
|
4
5
|
* Generates a virtual `_compile-entry.ts` that:
|
|
5
6
|
* 1. Statically imports every page module of every app so Bun bundles them
|
|
@@ -33,18 +33,8 @@ function buildEmbeddedContext(
|
|
|
33
33
|
];
|
|
34
34
|
}
|
|
35
35
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
* 1. Statically imports every page module of every app so Bun bundles them
|
|
39
|
-
* 2. Points embed-mode contexts at Bun's `compile.assets` directories
|
|
40
|
-
* 3. Sets production mode and registers one CompileContext PER APP
|
|
41
|
-
* 4. Dynamically imports server.ts to boot the composed app
|
|
42
|
-
*/
|
|
43
|
-
export function generateCompileEntry(options: BuildEntryOptions): VirtualBuildEntry {
|
|
44
|
-
const { apps, outDir, serverEntry, publicDir } = options;
|
|
45
|
-
ensureDir(outDir);
|
|
46
|
-
|
|
47
|
-
const preparedApps: EntryAppContext[] = apps.map((app) => {
|
|
36
|
+
export function prepareCompileEntryApps(options: BuildEntryOptions): EntryAppContext[] {
|
|
37
|
+
return options.apps.map((app) => {
|
|
48
38
|
const { embed, ...context } = app;
|
|
49
39
|
if (!embed) {
|
|
50
40
|
return context;
|
|
@@ -53,10 +43,24 @@ export function generateCompileEntry(options: BuildEntryOptions): VirtualBuildEn
|
|
|
53
43
|
...context,
|
|
54
44
|
extraContext: [
|
|
55
45
|
...(context.extraContext ?? []),
|
|
56
|
-
...buildEmbeddedContext(embed.clientDir, publicDir),
|
|
46
|
+
...buildEmbeddedContext(embed.clientDir, options.publicDir),
|
|
57
47
|
],
|
|
58
48
|
};
|
|
59
49
|
});
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Generates a virtual `_compile-entry.ts` that:
|
|
54
|
+
* 1. Statically imports every page module of every app so Bun bundles them
|
|
55
|
+
* 2. Points embed-mode contexts at Bun's `compile.assets` directories
|
|
56
|
+
* 3. Sets production mode and registers one CompileContext PER APP
|
|
57
|
+
* 4. Dynamically imports server.ts to boot the composed app
|
|
58
|
+
*/
|
|
59
|
+
export function generateCompileEntry(options: BuildEntryOptions): VirtualBuildEntry {
|
|
60
|
+
const { outDir, serverEntry } = options;
|
|
61
|
+
ensureDir(outDir);
|
|
62
|
+
|
|
63
|
+
const preparedApps = prepareCompileEntryApps(options);
|
|
60
64
|
|
|
61
65
|
const source = buildEntrySource({
|
|
62
66
|
apps: preparedApps,
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Kiana strips the WebSocket route module when an app has no WS route,
|
|
3
|
+
* but its capability plugin still imports four helpers omitted by that stub.
|
|
4
|
+
* Keep the upstream failure semantics while restoring the complete export
|
|
5
|
+
* surface. Remove this compatibility shim when Elysia ships the full stub.
|
|
6
|
+
*/
|
|
7
|
+
export declare function patchElysiaWebSocketStub(source: string): string;
|
|
8
|
+
/** Elysia AOT plugin with the no-WebSocket stub compatibility fix. */
|
|
9
|
+
export declare function elysiaAot(entry: string): Bun.BunPlugin;
|
|
@@ -4,6 +4,8 @@ export interface EntryAppContext {
|
|
|
4
4
|
buildId?: string;
|
|
5
5
|
/** Whether the emitted hydration client sends browser log batches. */
|
|
6
6
|
clientLogging?: boolean;
|
|
7
|
+
/** Deployment adapter that owns public page caching for this build. */
|
|
8
|
+
deploymentTarget?: "vercel";
|
|
7
9
|
/** Extra lines injected inside this app's `__setCompileContext({...})` call. */
|
|
8
10
|
extraContext?: string[];
|
|
9
11
|
/** Additional route modules such as filesystem-derived `_route` layouts. */
|
|
@@ -42,13 +44,15 @@ export interface EntryTemplateOptions {
|
|
|
42
44
|
/**
|
|
43
45
|
* - "boot" (default): forces production mode and dynamically imports the
|
|
44
46
|
* server entry after registering contexts — the whole app's entrypoint.
|
|
47
|
+
* - "app": registers contexts and exports the user's Elysia app without
|
|
48
|
+
* starting a listener, so build-time tooling can safely import it.
|
|
45
49
|
* - "register": ONLY registers contexts. Emitted by `--target package` as a
|
|
46
50
|
* side-effect module the HOST app imports; it must not touch dev mode or
|
|
47
51
|
* NODE_ENV (the host decides), and it imports furin internals via the
|
|
48
52
|
* package specifier so the host and the register module share ONE copy of
|
|
49
53
|
* the context registry (`packages: "external"` keeps it unbundled).
|
|
50
54
|
*/
|
|
51
|
-
mode?: "boot" | "register";
|
|
55
|
+
mode?: "app" | "boot" | "register";
|
|
52
56
|
/**
|
|
53
57
|
* Server entry to boot after context registration. Omitted in package
|
|
54
58
|
* (register-module) mode where the entry only registers contexts.
|
|
@@ -22,6 +22,8 @@ export interface EntryAppContext {
|
|
|
22
22
|
buildId?: string;
|
|
23
23
|
/** Whether the emitted hydration client sends browser log batches. */
|
|
24
24
|
clientLogging?: boolean;
|
|
25
|
+
/** Deployment adapter that owns public page caching for this build. */
|
|
26
|
+
deploymentTarget?: "vercel";
|
|
25
27
|
/** Extra lines injected inside this app's `__setCompileContext({...})` call. */
|
|
26
28
|
extraContext?: string[];
|
|
27
29
|
/** Additional route modules such as filesystem-derived `_route` layouts. */
|
|
@@ -57,13 +59,15 @@ export interface EntryTemplateOptions {
|
|
|
57
59
|
/**
|
|
58
60
|
* - "boot" (default): forces production mode and dynamically imports the
|
|
59
61
|
* server entry after registering contexts — the whole app's entrypoint.
|
|
62
|
+
* - "app": registers contexts and exports the user's Elysia app without
|
|
63
|
+
* starting a listener, so build-time tooling can safely import it.
|
|
60
64
|
* - "register": ONLY registers contexts. Emitted by `--target package` as a
|
|
61
65
|
* side-effect module the HOST app imports; it must not touch dev mode or
|
|
62
66
|
* NODE_ENV (the host decides), and it imports furin internals via the
|
|
63
67
|
* package specifier so the host and the register module share ONE copy of
|
|
64
68
|
* the context registry (`packages: "external"` keeps it unbundled).
|
|
65
69
|
*/
|
|
66
|
-
mode?: "boot" | "register";
|
|
70
|
+
mode?: "app" | "boot" | "register";
|
|
67
71
|
/**
|
|
68
72
|
* Server entry to boot after context registration. Omitted in package
|
|
69
73
|
* (register-module) mode where the entry only registers contexts.
|
|
@@ -152,6 +156,10 @@ function buildAppContextBlock(
|
|
|
152
156
|
const routeMetadataLine = app.routeMetadata
|
|
153
157
|
? ` routeMetadata: ${JSON.stringify(app.routeMetadata)},`
|
|
154
158
|
: "";
|
|
159
|
+
const deploymentTargetLine =
|
|
160
|
+
app.deploymentTarget === undefined
|
|
161
|
+
? ""
|
|
162
|
+
: ` deploymentTarget: ${JSON.stringify(app.deploymentTarget)},`;
|
|
155
163
|
const serveAssetsLine =
|
|
156
164
|
app.serveAssets === undefined ? "" : ` serveAssets: ${JSON.stringify(app.serveAssets)},`;
|
|
157
165
|
const ssgCacheLine = app.ssgCache ? ` ssgCache: ${JSON.stringify(app.ssgCache)},` : "";
|
|
@@ -162,6 +170,7 @@ function buildAppContextBlock(
|
|
|
162
170
|
"__setCompileContext({",
|
|
163
171
|
` buildId: ${JSON.stringify(app.buildId ?? "")},`,
|
|
164
172
|
` clientLogging: ${JSON.stringify(app.clientLogging ?? false)},`,
|
|
173
|
+
deploymentTargetLine,
|
|
165
174
|
` prefix: ${JSON.stringify(app.prefix ?? "")},`,
|
|
166
175
|
` rootPath: ${JSON.stringify(app.rootPath.replace(/\\/g, "/"))},`,
|
|
167
176
|
app.nativeRoutes ? ` nativeRoutes: ${nativeRoutesVar},` : "",
|
|
@@ -188,6 +197,7 @@ export function buildEntrySource(options: EntryTemplateOptions): string {
|
|
|
188
197
|
const mode = options.mode ?? "boot";
|
|
189
198
|
const internalSpecifier =
|
|
190
199
|
mode === "register" ? "@teyik0/furin/internal" : INTERNAL_MODULE_PATH;
|
|
200
|
+
const productionMode = mode !== "register";
|
|
191
201
|
|
|
192
202
|
const importLines: string[] = [];
|
|
193
203
|
const contextBlocks: string[] = [];
|
|
@@ -205,11 +215,11 @@ export function buildEntrySource(options: EntryTemplateOptions): string {
|
|
|
205
215
|
const lines = [
|
|
206
216
|
headerComment,
|
|
207
217
|
`import { __setCompileContext } from ${JSON.stringify(internalSpecifier)};`,
|
|
208
|
-
...(
|
|
218
|
+
...(productionMode
|
|
209
219
|
? [`import { __setDevMode } from ${JSON.stringify(RUNTIME_ENV_MODULE_PATH)};`]
|
|
210
220
|
: []),
|
|
211
221
|
...importLines,
|
|
212
|
-
...(
|
|
222
|
+
...(productionMode
|
|
213
223
|
? [
|
|
214
224
|
"",
|
|
215
225
|
"// Force production mode — Bun may inline process.env.NODE_ENV at bundle time.",
|
|
@@ -219,7 +229,7 @@ export function buildEntrySource(options: EntryTemplateOptions): string {
|
|
|
219
229
|
: []),
|
|
220
230
|
...contextBlocks,
|
|
221
231
|
"",
|
|
222
|
-
...(serverEntry
|
|
232
|
+
...(serverEntry && mode === "boot"
|
|
223
233
|
? [
|
|
224
234
|
`const __serverModule = await import(${JSON.stringify(serverEntry.replace(/\\/g, "/"))});`,
|
|
225
235
|
"if (typeof __serverModule.startServer === \"function\") {",
|
|
@@ -239,7 +249,16 @@ export function buildEntrySource(options: EntryTemplateOptions): string {
|
|
|
239
249
|
"}",
|
|
240
250
|
"",
|
|
241
251
|
]
|
|
242
|
-
:
|
|
252
|
+
: serverEntry && mode === "app"
|
|
253
|
+
? [
|
|
254
|
+
`const __serverModule = await import(${JSON.stringify(serverEntry.replace(/\\/g, "/"))});`,
|
|
255
|
+
"export const app = __serverModule.default;",
|
|
256
|
+
"export const port = __serverModule.port;",
|
|
257
|
+
"export const startServer = __serverModule.startServer;",
|
|
258
|
+
"export default __serverModule.default;",
|
|
259
|
+
"",
|
|
260
|
+
]
|
|
261
|
+
: []),
|
|
243
262
|
];
|
|
244
263
|
|
|
245
264
|
return lines.join("\n");
|