@teyik0/furin 0.8.0-alpha.0 → 0.9.0-alpha.0
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 +37 -0
- package/dist/adapter/bun/app.d.ts +1 -0
- package/dist/adapter/bun.d.ts +3 -1
- package/dist/adapter/runtime-build.d.ts +8 -5
- package/dist/adapter/vercel.js +8 -8
- package/dist/build/client.d.ts +2 -2
- package/dist/build/discover-mounts-process.d.ts +1 -1
- package/dist/build/discover-pages-process.d.ts +1 -0
- package/dist/build/discover-pages.d.ts +11 -0
- package/dist/build/discovery-module.d.ts +3 -0
- package/dist/build/discovery-plugins.d.ts +34 -0
- package/dist/build/elysia-aot.d.ts +1 -1
- package/dist/build/entry-template.ts +6 -1
- package/dist/build/hydrate.d.ts +3 -2
- package/dist/build/index.js +7688 -8458
- package/dist/build/preload-manifest.d.ts +2 -2
- package/dist/build/route-metadata.d.ts +31 -0
- package/dist/build/route-types.d.ts +1 -1
- package/dist/build/shared.d.ts +2 -2
- package/dist/build/types.d.ts +11 -0
- package/dist/cli/dev-worker.d.ts +1 -0
- package/dist/cli/dev-worker.ts +123 -0
- package/dist/cli/dev.d.ts +1 -0
- package/dist/cli/index.js +7811 -8477
- package/dist/client/browser-events-runtime.d.ts +2 -2
- package/dist/client/browser-events.d.ts +2 -0
- package/dist/client/chunks/{client-brdfd773.js → client-rjhxgt64.js} +187 -4
- package/dist/client/dev-error-overlay.ts +18 -1
- package/dist/client/link.js +110 -156
- package/dist/client/query-store.d.ts +5 -0
- package/dist/client/router/navigation-controller.d.ts +2 -0
- package/dist/client/router/use-fetch-interception.d.ts +1 -1
- package/dist/client/router/use-sync-stream.d.ts +1 -1
- package/dist/client/{router/sync-catch-up.d.ts → sync-catch-up.d.ts} +5 -3
- package/dist/client/sync-client.d.ts +74 -0
- package/dist/client.d.ts +1 -0
- package/dist/client.js +533 -145
- package/dist/config.d.ts +6 -1
- package/dist/config.js +3 -1
- package/dist/define-route.d.ts +3 -3
- package/dist/furin.d.ts +2 -1
- package/dist/furin.js +1119 -346
- package/dist/plugin/index.js +5 -5
- package/dist/plugin/route-registry.d.ts +22 -2
- package/dist/rsc/build/index.d.ts +4 -3
- package/dist/server/dev/server-only-module.d.ts +5 -0
- package/dist/server/internal.js +201 -91
- package/dist/server/logging/ingest-plugin.d.ts +1 -2
- package/dist/server/production-server.js +36 -33
- package/dist/server/server-entry.d.ts +5 -0
- package/dist/server/server-entry.js +36 -0
- package/dist/server/static-export.js +201 -91
- package/dist/server/sync/adapter.d.ts +4 -3
- package/dist/server/sync/config.d.ts +7 -0
- package/dist/server/sync/connection.d.ts +13 -0
- package/dist/server/sync/drizzle/index.js +5 -4
- package/dist/server/sync/index.d.ts +3 -0
- package/dist/server/sync/index.js +1361 -243
- package/dist/server/sync/invalidate-sync.d.ts +6 -2
- package/dist/server/sync/local-client.d.ts +9 -0
- package/dist/server/sync/postgres/index.d.ts +1 -1
- package/dist/server/sync/postgres/index.js +2 -2
- package/dist/server/sync/prisma/index.js +2 -2
- package/dist/server/sync/redis/index.d.ts +1 -1
- package/dist/server/sync/redis/index.js +4 -3
- package/dist/server/sync/redis/scripts.d.ts +1 -1
- package/dist/server/sync/runtime.d.ts +3 -0
- package/dist/server/sync/sqlite/index.d.ts +1 -1
- package/dist/server/sync/sqlite/index.js +3 -2
- package/dist/shared/browser-events.d.ts +4 -0
- package/dist/sync-client.d.ts +3 -0
- package/dist/sync-client.js +1600 -0
- package/package.json +12 -7
- package/src/adapter/README.md +7 -0
- package/src/adapter/build.ts +34 -33
- package/src/adapter/bun/app.ts +5 -0
- package/src/adapter/bun/server.ts +2 -2
- package/src/adapter/bun.ts +18 -2
- package/src/adapter/furin-app.d.ts +1 -0
- package/src/adapter/package.ts +1 -0
- package/src/adapter/runtime-build.ts +18 -12
- package/src/adapter/static.ts +17 -13
- package/src/build/client.ts +7 -5
- package/src/build/discover-mounts-process.ts +5 -1
- package/src/build/discover-pages-process.ts +151 -0
- package/src/build/discover-pages.ts +69 -0
- package/src/build/discovery-module.ts +70 -0
- package/src/build/discovery-plugins.ts +101 -0
- package/src/build/elysia-aot-worker.ts +9 -8
- package/src/build/elysia-aot.ts +110 -75
- package/src/build/entry-template.ts +6 -1
- package/src/build/hydrate.ts +11 -8
- package/src/build/index.ts +6 -50
- package/src/build/preload-manifest.ts +3 -3
- package/src/build/route-metadata.ts +90 -0
- package/src/build/route-types.ts +1 -1
- package/src/build/shared.ts +6 -8
- package/src/build/types.ts +9 -0
- package/src/cli/config.ts +4 -0
- package/src/cli/dev-worker.ts +123 -0
- package/src/cli/dev.ts +91 -0
- package/src/cli/index.ts +24 -1
- package/src/client/browser-events-runtime.ts +97 -23
- package/src/client/browser-events.ts +8 -0
- package/src/client/dev-error-overlay.ts +18 -1
- package/src/client/query-store.ts +54 -3
- package/src/client/router/navigation-controller.ts +45 -12
- package/src/client/router/provider.tsx +6 -2
- package/src/client/router/use-fetch-interception.ts +1 -1
- package/src/client/router/use-sync-stream.ts +96 -44
- package/src/client/{router/sync-catch-up.ts → sync-catch-up.ts} +28 -12
- package/src/client/sync-client.ts +528 -0
- package/src/client/sync.ts +11 -4
- package/src/client.ts +10 -0
- package/src/config.ts +17 -10
- package/src/furin.ts +5 -0
- package/src/plugin/route-registry.ts +53 -7
- package/src/rsc/build/index.ts +6 -3
- package/src/server/browser-events/plugin.ts +79 -25
- package/src/server/dev/rewrite-module-specifiers.ts +2 -1
- package/src/server/dev/server-only-module.ts +23 -0
- package/src/server/dev/symbolicate.ts +4 -3
- package/src/server/dev-page-imports.ts +3 -1
- package/src/server/dev-page-plugin.ts +18 -1
- package/src/server/logging/ingest-plugin.ts +3 -9
- package/src/server/server-entry.ts +39 -0
- package/src/server/sync/adapter.ts +7 -3
- package/src/server/sync/config.ts +12 -6
- package/src/server/sync/connection.ts +71 -0
- package/src/server/sync/index.ts +3 -0
- package/src/server/sync/invalidate-sync.ts +30 -5
- package/src/server/sync/local-client.ts +84 -0
- package/src/server/sync/plugin.ts +27 -20
- package/src/server/sync/postgres/index.ts +9 -2
- package/src/server/sync/redis/index.ts +5 -1
- package/src/server/sync/redis/scripts.ts +1 -1
- package/src/server/sync/runtime.ts +56 -18
- package/src/server/sync/sqlite/index.ts +6 -2
- package/src/server/sync/stream.ts +17 -5
- package/src/shared/browser-events.ts +1 -1
- package/src/sync-client.ts +14 -0
- package/dist/server/logger.d.ts +0 -10
- package/src/server/logger.ts +0 -34
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { BuildRouteInput } from "./route-metadata.ts";
|
|
2
2
|
/** Chunk URLs to `<link rel="modulepreload">`, derived from the client build graph. */
|
|
3
3
|
export interface ClientPreloadManifest {
|
|
4
4
|
/** `clientModule()` key → the module's chunk and its transitive static imports. */
|
|
@@ -14,4 +14,4 @@ export interface ClientPreloadManifest {
|
|
|
14
14
|
* after hashing is safe: its hash covers the hashes of every chunk it imports,
|
|
15
15
|
* so the URLs it now embeds can only change when its own name changes.
|
|
16
16
|
*/
|
|
17
|
-
export declare function writeClientPreloadManifest(metafile: Bun.BuildMetafile, outputPaths: string[], entryChunkPath: string, routes:
|
|
17
|
+
export declare function writeClientPreloadManifest(metafile: Bun.BuildMetafile, outputPaths: string[], entryChunkPath: string, routes: BuildRouteInput[], publicPrefix: string): ClientPreloadManifest;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { ResolvedRoute, RootLayout, SegmentBoundary } from "../server/router/types.ts";
|
|
2
|
+
import { type SearchParamsInput } from "../shared/search-params.ts";
|
|
3
|
+
interface RouteBuildInfo {
|
|
4
|
+
documentMode: ResolvedRoute["mode"];
|
|
5
|
+
documentRevalidate: number | undefined;
|
|
6
|
+
hasLayout: boolean;
|
|
7
|
+
hasRequestLoader: boolean;
|
|
8
|
+
hasStaticParams: boolean;
|
|
9
|
+
mixed: boolean;
|
|
10
|
+
queryKeys: string[] | null;
|
|
11
|
+
revalidate: number | undefined;
|
|
12
|
+
searchDefaults: SearchParamsInput | undefined;
|
|
13
|
+
}
|
|
14
|
+
/** Discovery results contain data only; application closures stay in the child. */
|
|
15
|
+
export interface BuildRoute extends Pick<ResolvedRoute, "mode" | "path" | "pattern" | "requestKeys" | "requestKeysByLoader" | "tags"> {
|
|
16
|
+
build: RouteBuildInfo;
|
|
17
|
+
routeChain: {
|
|
18
|
+
layout: boolean;
|
|
19
|
+
sourcePath?: string;
|
|
20
|
+
}[];
|
|
21
|
+
segmentBoundaries: Pick<SegmentBoundary, "depth" | "path" | "errorPath" | "notFoundPath">[];
|
|
22
|
+
}
|
|
23
|
+
export type BuildRouteInput = BuildRoute | ResolvedRoute;
|
|
24
|
+
export type BuildRoot = Pick<RootLayout, "path" | "errorPath" | "notFoundPath"> & {
|
|
25
|
+
hasRequestLoader: boolean;
|
|
26
|
+
};
|
|
27
|
+
export declare function rootHasRequestLoader(root: BuildRoot | RootLayout): boolean;
|
|
28
|
+
/** Also accepts live routes for the public buildClient API and dev hydration. */
|
|
29
|
+
export declare function routeBuildInfo(route: BuildRouteInput): RouteBuildInfo;
|
|
30
|
+
export declare function buildRouteMetadata(route: ResolvedRoute): BuildRoute;
|
|
31
|
+
export {};
|
|
@@ -6,4 +6,4 @@ import type { ResolvedRoute } from "../server/router/types.ts";
|
|
|
6
6
|
* `FileRoutes`. Without `apps`, `FileRoutes` is not declared and
|
|
7
7
|
* `defineRoute(id)` accepts any id.
|
|
8
8
|
*/
|
|
9
|
-
export declare function writeRouteTypes(routes: ResolvedRoute[], projectRoot: string, apps?: readonly RouteInstanceSpec[]): boolean;
|
|
9
|
+
export declare function writeRouteTypes(routes: Pick<ResolvedRoute, "path" | "pattern" | "tags">[], projectRoot: string, apps?: readonly RouteInstanceSpec[]): boolean;
|
package/dist/build/shared.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type BuildRouteInput } from "./route-metadata.ts";
|
|
2
2
|
import type { BuildRouteManifestEntry } from "./types";
|
|
3
3
|
export declare const CLIENT_MODULE_PATH: string;
|
|
4
4
|
export declare const LINK_MODULE_PATH: string;
|
|
@@ -7,4 +7,4 @@ export declare function toPosixPath(path: string): string;
|
|
|
7
7
|
/** Writes a Bun build metafile (`furin build --analyze`) and logs where it went. */
|
|
8
8
|
export declare function writeBuildMetafile(path: string, metafile: Bun.BuildMetafile, label: string): void;
|
|
9
9
|
export declare function copyDirRecursive(sourceDir: string, targetDir: string): void;
|
|
10
|
-
export declare function toBuildRouteManifestEntry(route:
|
|
10
|
+
export declare function toBuildRouteManifestEntry(route: BuildRouteInput, rootDir: string): BuildRouteManifestEntry;
|
package/dist/build/types.d.ts
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
import type { AdapterTargetManifest } from "../adapter/types.ts";
|
|
2
2
|
import type { FurinTarget, StaticExportConfig } from "../config";
|
|
3
|
+
import type { RouteRegistrySnapshot } from "../plugin/route-registry.ts";
|
|
3
4
|
import type { ResolvedRoute } from "../server/router/types.ts";
|
|
4
5
|
import type { ClientBoundary } from "../rsc/build/discover.ts";
|
|
5
6
|
export interface BuildClientOptions {
|
|
7
|
+
/** Route registry evaluated in the discovery process. */
|
|
8
|
+
routeRegistry?: RouteRegistrySnapshot;
|
|
6
9
|
/**
|
|
7
10
|
* Sub-path prefix for the deployment (e.g. "/furin" for GitHub Pages).
|
|
8
11
|
* Passed through to the generated hydrate entry so SPA navigation uses
|
|
@@ -46,6 +49,8 @@ export interface BuildRouteManifestEntry {
|
|
|
46
49
|
revalidate: number | null;
|
|
47
50
|
}
|
|
48
51
|
export interface TargetBuildManifest {
|
|
52
|
+
/** Importable, inert Bun application; absent for listening server outputs. */
|
|
53
|
+
appPath?: string;
|
|
49
54
|
buildId: string;
|
|
50
55
|
clientDir: string | null;
|
|
51
56
|
generatedAt: string;
|
|
@@ -90,6 +95,10 @@ export interface BuildManifest {
|
|
|
90
95
|
export interface BuildAppOptions {
|
|
91
96
|
/** Emit Bun metafiles for client and supported server bundle analysis. */
|
|
92
97
|
analyze?: boolean;
|
|
98
|
+
/** Bun emits a listening server unless output is explicitly "app". */
|
|
99
|
+
bun?: {
|
|
100
|
+
output?: "app" | "server";
|
|
101
|
+
};
|
|
93
102
|
/**
|
|
94
103
|
* Explicit multi-app build (furin.config.ts `apps`). Overrides `pagesDir`
|
|
95
104
|
* and the mounts found by evaluating the server entry.
|
|
@@ -110,6 +119,8 @@ export interface BuildAppOptions {
|
|
|
110
119
|
reactCompiler?: boolean;
|
|
111
120
|
rootDir?: string;
|
|
112
121
|
serverEntry?: string;
|
|
122
|
+
/** Runtime packages excluded from server and RSC bundles, including their subpaths. */
|
|
123
|
+
serverExternalPackages?: string[];
|
|
113
124
|
/** Emit server source maps outside deployable output directories. */
|
|
114
125
|
serverSourceMaps?: boolean;
|
|
115
126
|
/** Configuration for the `static` build target. */
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import "elysia";
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
import { pathToFileURL } from "node:url";
|
|
2
|
+
import "elysia";
|
|
3
|
+
import type { AnyElysia } from "elysia";
|
|
4
|
+
import { BunAdapter } from "elysia/adapter/bun";
|
|
5
|
+
|
|
6
|
+
interface WebDevelopment {
|
|
7
|
+
load: <T>(load: () => Promise<T>) => Promise<T>;
|
|
8
|
+
ready: (app: AnyElysia) => Promise<void>;
|
|
9
|
+
stop: () => Promise<void>;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
// Bun hot reload retains the global owner, not the old imported module graph.
|
|
13
|
+
const key: unique symbol = Symbol.for("@teyik0/furin/web-dev");
|
|
14
|
+
const global = globalThis as typeof globalThis & {
|
|
15
|
+
[key]?: { dispose: () => Promise<void>; cancel: () => Promise<void> };
|
|
16
|
+
};
|
|
17
|
+
const previous = global[key];
|
|
18
|
+
if (previous) {
|
|
19
|
+
process.off("SIGINT", previous.cancel);
|
|
20
|
+
process.off("SIGTERM", previous.cancel);
|
|
21
|
+
process.off("message", previous.cancel);
|
|
22
|
+
await previous.dispose();
|
|
23
|
+
}
|
|
24
|
+
const [, , entry, port, integration] = process.argv;
|
|
25
|
+
if (!entry) {
|
|
26
|
+
throw new Error("Missing development server entry.");
|
|
27
|
+
}
|
|
28
|
+
let app: AnyElysia | undefined;
|
|
29
|
+
let web: WebDevelopment | undefined;
|
|
30
|
+
const dispose = async () => {
|
|
31
|
+
try {
|
|
32
|
+
await app?.stop(true);
|
|
33
|
+
} finally {
|
|
34
|
+
await web?.stop();
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
let stopping: Promise<void> | undefined;
|
|
38
|
+
const stop = (status: number) => {
|
|
39
|
+
stopping ??= (async () => {
|
|
40
|
+
let code = status;
|
|
41
|
+
const timer = setTimeout(() => process.exit(1), 5000);
|
|
42
|
+
try {
|
|
43
|
+
await dispose();
|
|
44
|
+
} catch (error) {
|
|
45
|
+
console.error(error);
|
|
46
|
+
code = 1;
|
|
47
|
+
} finally {
|
|
48
|
+
clearTimeout(timer);
|
|
49
|
+
process.exit(code);
|
|
50
|
+
}
|
|
51
|
+
})();
|
|
52
|
+
return stopping;
|
|
53
|
+
};
|
|
54
|
+
const cancel = () => stop(0);
|
|
55
|
+
global[key] = { dispose, cancel };
|
|
56
|
+
process.on("SIGINT", cancel);
|
|
57
|
+
process.on("SIGTERM", cancel);
|
|
58
|
+
process.on("message", cancel);
|
|
59
|
+
const timer = setTimeout(() => {
|
|
60
|
+
console.error("Web development startup exceeded 30 seconds.");
|
|
61
|
+
stop(1).catch(console.error);
|
|
62
|
+
}, 30_000);
|
|
63
|
+
try {
|
|
64
|
+
if (integration) {
|
|
65
|
+
const addon: { createWebDevelopment: () => WebDevelopment } = await import(
|
|
66
|
+
pathToFileURL(integration).href
|
|
67
|
+
);
|
|
68
|
+
web = addon.createWebDevelopment();
|
|
69
|
+
}
|
|
70
|
+
const { listen } = BunAdapter;
|
|
71
|
+
if (!listen) {
|
|
72
|
+
throw new Error("Web development requires Elysia's Bun adapter.");
|
|
73
|
+
}
|
|
74
|
+
const ready = Promise.withResolvers<void>();
|
|
75
|
+
// Source import can fail after a startup failure has already rejected readiness.
|
|
76
|
+
ready.promise.catch(() => undefined);
|
|
77
|
+
BunAdapter.listen = (root, options, callback) => {
|
|
78
|
+
if (app) {
|
|
79
|
+
throw new Error("Web development supports one application listener.");
|
|
80
|
+
}
|
|
81
|
+
app = root;
|
|
82
|
+
root.onStop(() => ready.reject(new Error("Web development startup failed.")));
|
|
83
|
+
if (typeof options === "object" && options.unix !== undefined) {
|
|
84
|
+
throw new Error("Web development requires a TCP listener.");
|
|
85
|
+
}
|
|
86
|
+
const settings = port
|
|
87
|
+
? { ...(typeof options === "object" ? options : {}), unix: undefined, port: Number(port) }
|
|
88
|
+
: options;
|
|
89
|
+
return listen(root, settings, (server) => {
|
|
90
|
+
callback?.(server);
|
|
91
|
+
ready.resolve();
|
|
92
|
+
});
|
|
93
|
+
};
|
|
94
|
+
try {
|
|
95
|
+
const load = (): Promise<{ default?: AnyElysia; app?: AnyElysia }> =>
|
|
96
|
+
import(pathToFileURL(entry).href);
|
|
97
|
+
const module = await (web ? web.load(load) : load());
|
|
98
|
+
const exported = module.default ?? module.app;
|
|
99
|
+
if (app && exported && exported !== app) {
|
|
100
|
+
throw new Error("Default-export the listening Elysia app.");
|
|
101
|
+
}
|
|
102
|
+
if (!app) {
|
|
103
|
+
if (!exported || typeof exported.listen !== "function") {
|
|
104
|
+
throw new Error("Listen on or default-export an Elysia app.");
|
|
105
|
+
}
|
|
106
|
+
exported.listen({ hostname: "127.0.0.1", port: 3000 });
|
|
107
|
+
}
|
|
108
|
+
await ready.promise;
|
|
109
|
+
} finally {
|
|
110
|
+
BunAdapter.listen = listen;
|
|
111
|
+
}
|
|
112
|
+
const activeApp = app;
|
|
113
|
+
if (!activeApp) {
|
|
114
|
+
throw new Error("Web development did not start a listener.");
|
|
115
|
+
}
|
|
116
|
+
await web?.ready(activeApp);
|
|
117
|
+
clearTimeout(timer);
|
|
118
|
+
console.log(`[furin] Web development: ${activeApp.server?.url.origin}`);
|
|
119
|
+
} catch (error) {
|
|
120
|
+
clearTimeout(timer);
|
|
121
|
+
console.error(error);
|
|
122
|
+
await stop(1);
|
|
123
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function runDevelopment(cwd: string, args: string[]): Promise<void>;
|