@teyik0/furin 0.4.0-alpha.2 → 0.5.0-alpha.2
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 +27 -6
- package/dist/build/index.js +969 -528
- package/dist/build/private-server-sourcemaps.d.ts +2 -0
- package/dist/build/server-app-entry.d.ts +12 -0
- package/dist/build/types.d.ts +2 -0
- package/dist/cache.d.ts +1 -0
- package/dist/cache.js +185 -0
- package/dist/cli/index.js +983 -541
- package/dist/client/document.d.ts +2 -0
- package/dist/client/internal/runtime-types.d.ts +8 -1
- package/dist/client/link.js +232 -11
- package/dist/client/sync.d.ts +1 -0
- package/dist/client.js +11 -0
- package/dist/config.d.ts +28 -22
- package/dist/config.js +25 -2
- package/dist/define-route.d.ts +273 -1009
- package/dist/furin.d.ts +20 -5
- package/dist/furin.js +6431 -5457
- package/dist/plugin/routes.d.ts +6 -0
- package/dist/rsc-client.js +9 -1
- package/dist/rsc.js +19 -7
- 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/browser-events/shutdown.d.ts +3 -0
- 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 +41 -0
- package/dist/server/cache/redis/index.js +451 -0
- package/dist/server/cache/redis/scripts.d.ts +6 -0
- package/dist/server/context-logger.d.ts +2 -2
- package/dist/server/dev/plugin.d.ts +1 -0
- 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 +2539 -0
- package/dist/server/production-server.d.ts +13 -0
- package/dist/server/production-server.js +2906 -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/hmr.d.ts +6 -0
- package/dist/server/router/hmr.production.d.ts +5 -0
- package/dist/server/router/plugin.d.ts +5 -1
- package/dist/server/router/schemas.d.ts +1 -0
- package/dist/server/sync/index.js +798 -117
- package/dist/server/sync/plugin.d.ts +31 -158
- package/dist/server/sync/stream.d.ts +38 -49
- package/dist/shared/elysia-contract.d.ts +8 -14
- package/dist/shared/production-build.d.ts +2 -0
- package/package.json +19 -8
- package/src/adapter/README.md +9 -2
- package/src/adapter/bun.ts +146 -41
- 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 +64 -31
- 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 +27 -6
- package/src/build/hydrate.ts +5 -1
- package/src/build/index.ts +5 -5
- package/src/build/private-server-sourcemaps.ts +20 -0
- package/src/build/production-instrumentation.ts +2 -2
- package/src/build/server-app-entry.ts +61 -0
- package/src/build/shared.ts +3 -1
- package/src/build/ssg-cache.ts +5 -10
- package/src/build/types.ts +2 -0
- 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 +6 -2
- package/src/client/document.tsx +19 -0
- package/src/client/internal/runtime-types.ts +10 -1
- package/src/client/sync.ts +1 -0
- package/src/config.ts +33 -4
- package/src/define-route.ts +266 -128
- package/src/furin.ts +168 -154
- package/src/plugin/route-config-autofix.ts +11 -2
- package/src/plugin/routes.ts +85 -29
- package/src/rsc/codec.ts +11 -6
- package/src/rsc/render-error.ts +3 -1
- 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 +13 -1
- package/src/server/browser-events/shutdown.ts +32 -0
- 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 +367 -0
- package/src/server/cache/redis/scripts.ts +200 -0
- package/src/server/context-logger.ts +5 -5
- package/src/server/dev/plugin.ts +10 -1
- package/src/server/dev/runtime.production.ts +4 -0
- package/src/server/dev-page-plugin.ts +54 -10
- package/src/server/evlog.ts +106 -0
- package/src/server/internal.ts +7 -0
- package/src/server/production-server.ts +135 -0
- package/src/server/render/document.tsx +7 -1
- 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 +6 -7
- package/src/server/render/static-params.ts +174 -0
- package/src/server/render/template.ts +5 -1
- package/src/server/router/defined-route.ts +2 -1
- package/src/server/router/discovery.ts +3 -1
- package/src/server/router/hmr.production.ts +11 -0
- package/src/server/router/hmr.ts +85 -76
- package/src/server/router/plugin.ts +118 -50
- package/src/server/router/schema-merge.ts +10 -3
- 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/server/sync/stream.ts +43 -2
- package/src/shared/elysia-contract.ts +23 -25
- package/src/shared/production-build.ts +20 -0
package/dist/plugin/routes.d.ts
CHANGED
|
@@ -17,8 +17,14 @@ export interface DevRouteTopologyWatcherOptions {
|
|
|
17
17
|
onTopologyChange: (sourcePaths: readonly string[]) => Promise<void> | void;
|
|
18
18
|
}
|
|
19
19
|
export declare function routeModuleSpecifier(instance: RouteInstanceSpec): string;
|
|
20
|
+
export declare function composableRouteModuleSpecifier(instance: RouteInstanceSpec): string;
|
|
20
21
|
export declare function routeSourcePaths(instance: RouteInstanceSpec): string[];
|
|
21
22
|
export declare function registerDevRouteTopologyWatcher(options: DevRouteTopologyWatcherOptions): DevRouteTopologyWatcher;
|
|
23
|
+
/**
|
|
24
|
+
* Emits a real server route module for build-time consumers such as Elysia's
|
|
25
|
+
* AOT plugin, which imports the application outside Bun's virtual module graph.
|
|
26
|
+
*/
|
|
27
|
+
export declare function materializedRouteModuleSource(instance: RouteInstanceSpec): Promise<string>;
|
|
22
28
|
export declare function validateRouteParams(path: string, schemas: {
|
|
23
29
|
params?: {
|
|
24
30
|
properties?: object;
|
package/dist/rsc-client.js
CHANGED
|
@@ -1,4 +1,10 @@
|
|
|
1
1
|
// @bun
|
|
2
|
+
// src/shared/production-build.ts
|
|
3
|
+
var productionBuildScope;
|
|
4
|
+
function isProductionBuild() {
|
|
5
|
+
return productionBuildScope?.getStore() === true || typeof process !== "undefined" && false;
|
|
6
|
+
}
|
|
7
|
+
|
|
2
8
|
// src/rsc/render-error.ts
|
|
3
9
|
var INTERNAL_STACK_FRAMES = new Set([
|
|
4
10
|
"<anonymous>",
|
|
@@ -16,7 +22,9 @@ function errorStack(error) {
|
|
|
16
22
|
return error instanceof Error ? error.stack : undefined;
|
|
17
23
|
}
|
|
18
24
|
function renderErrorMessage(options) {
|
|
19
|
-
if (
|
|
25
|
+
if (isProductionBuild()) {
|
|
26
|
+
return `[furin/rsc] Server Component rendering failed inside ${options.operation}().`;
|
|
27
|
+
}
|
|
20
28
|
if (options.hook !== undefined && options.component !== undefined) {
|
|
21
29
|
const diagnostic = `[furin/rsc] A component rendered inside ${options.operation}()
|
|
22
30
|
used a client-only React hook.
|
package/dist/rsc.js
CHANGED
|
@@ -8,6 +8,12 @@ import { tmpdir } from "os";
|
|
|
8
8
|
import { dirname, isAbsolute, join, resolve } from "path";
|
|
9
9
|
import { pathToFileURL } from "url";
|
|
10
10
|
|
|
11
|
+
// src/shared/production-build.ts
|
|
12
|
+
var productionBuildScope;
|
|
13
|
+
function isProductionBuild() {
|
|
14
|
+
return productionBuildScope?.getStore() === true || typeof process !== "undefined" && false;
|
|
15
|
+
}
|
|
16
|
+
|
|
11
17
|
// src/rsc/render-error.ts
|
|
12
18
|
var INTERNAL_STACK_FRAMES = new Set([
|
|
13
19
|
"<anonymous>",
|
|
@@ -45,7 +51,9 @@ function detectComponent(error, hook) {
|
|
|
45
51
|
}
|
|
46
52
|
}
|
|
47
53
|
function renderErrorMessage(options) {
|
|
48
|
-
if (
|
|
54
|
+
if (isProductionBuild()) {
|
|
55
|
+
return `[furin/rsc] Server Component rendering failed inside ${options.operation}().`;
|
|
56
|
+
}
|
|
49
57
|
if (options.hook !== undefined && options.component !== undefined) {
|
|
50
58
|
const diagnostic = `[furin/rsc] A component rendered inside ${options.operation}()
|
|
51
59
|
used a client-only React hook.
|
|
@@ -149,7 +157,7 @@ async function drainFlight(session, operation) {
|
|
|
149
157
|
}
|
|
150
158
|
|
|
151
159
|
// src/rsc/codec.ts
|
|
152
|
-
var
|
|
160
|
+
var serverCodecPromises = new Map;
|
|
153
161
|
function resolveConfiguredCodecPath(configuredPath) {
|
|
154
162
|
if (configuredPath === undefined || configuredPath.trim() === "") {
|
|
155
163
|
return;
|
|
@@ -165,10 +173,12 @@ function resolveBuiltCodecPath(moduleDir, executablePath) {
|
|
|
165
173
|
return candidates.find((candidate) => existsSync(candidate));
|
|
166
174
|
}
|
|
167
175
|
function loadServerCodec() {
|
|
168
|
-
|
|
169
|
-
|
|
176
|
+
const mode = isProductionBuild() ? "production" : "development";
|
|
177
|
+
const existing = serverCodecPromises.get(mode);
|
|
178
|
+
if (existing !== undefined) {
|
|
179
|
+
return existing;
|
|
170
180
|
}
|
|
171
|
-
|
|
181
|
+
const codecPromise = (async () => {
|
|
172
182
|
const configuredCodecPath = resolveConfiguredCodecPath(process.env.FURIN_RSC_CODEC_PATH);
|
|
173
183
|
if (configuredCodecPath !== undefined) {
|
|
174
184
|
return import(pathToFileURL(configuredCodecPath).href);
|
|
@@ -177,7 +187,7 @@ function loadServerCodec() {
|
|
|
177
187
|
if (builtCodecPath !== undefined) {
|
|
178
188
|
return import(pathToFileURL(builtCodecPath).href);
|
|
179
189
|
}
|
|
180
|
-
const outdir = join(tmpdir(), `furin-rsc-${process.pid}-${Bun.hash(import.meta.url)}`);
|
|
190
|
+
const outdir = join(tmpdir(), `furin-rsc-${process.pid}-${Bun.hash(import.meta.url)}-${mode}`);
|
|
181
191
|
mkdirSync(outdir, { recursive: true });
|
|
182
192
|
const sourcePath = join(import.meta.dir, "server-codec.ts");
|
|
183
193
|
if (!existsSync(sourcePath)) {
|
|
@@ -185,6 +195,7 @@ function loadServerCodec() {
|
|
|
185
195
|
}
|
|
186
196
|
const result = await Bun.build({
|
|
187
197
|
conditions: ["react-server"],
|
|
198
|
+
define: { "process.env.NODE_ENV": JSON.stringify(mode) },
|
|
188
199
|
entrypoints: [sourcePath],
|
|
189
200
|
format: "esm",
|
|
190
201
|
minify: false,
|
|
@@ -204,7 +215,8 @@ ${details}`);
|
|
|
204
215
|
}
|
|
205
216
|
return import(pathToFileURL(output.path).href);
|
|
206
217
|
})();
|
|
207
|
-
|
|
218
|
+
serverCodecPromises.set(mode, codecPromise);
|
|
219
|
+
return codecPromise;
|
|
208
220
|
}
|
|
209
221
|
async function encodeFlight(model, signal, operation) {
|
|
210
222
|
const codec = await loadServerCodec();
|
|
@@ -1,38 +1,22 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Elysia } from "elysia";
|
|
2
|
+
import { isSuccessfulMutationResponse } from "./runtime.ts";
|
|
2
3
|
import type { InvalidationInput } from "./types.ts";
|
|
3
|
-
type AnyAfterHandleContext = Parameters<
|
|
4
|
-
export declare function furinInvalidate(): Elysia<"", {
|
|
5
|
-
decorator: {};
|
|
6
|
-
store: {};
|
|
7
|
-
derive: {};
|
|
8
|
-
resolve: {};
|
|
9
|
-
}, {
|
|
4
|
+
type AnyAfterHandleContext = Parameters<typeof isSuccessfulMutationResponse>[0];
|
|
5
|
+
export declare function furinInvalidate(): Elysia<"", "local", import("elysia").DefaultSingleton, {
|
|
10
6
|
typebox: {};
|
|
11
|
-
error:
|
|
7
|
+
error: [];
|
|
12
8
|
}, {
|
|
13
9
|
schema: {};
|
|
14
|
-
|
|
10
|
+
schemas: {};
|
|
15
11
|
macro: Partial<{
|
|
16
12
|
readonly invalidate: InvalidationInput;
|
|
17
13
|
}>;
|
|
18
14
|
macroFn: {
|
|
19
15
|
readonly invalidate: (rules: InvalidationInput) => {
|
|
20
|
-
|
|
16
|
+
afterHandle(ctx: AnyAfterHandleContext): Promise<void>;
|
|
21
17
|
};
|
|
22
18
|
};
|
|
23
19
|
parser: {};
|
|
24
20
|
response: {};
|
|
25
|
-
}, {},
|
|
26
|
-
derive: {};
|
|
27
|
-
resolve: {};
|
|
28
|
-
schema: {};
|
|
29
|
-
standaloneSchema: {};
|
|
30
|
-
response: {};
|
|
31
|
-
}, {
|
|
32
|
-
derive: {};
|
|
33
|
-
resolve: {};
|
|
34
|
-
schema: {};
|
|
35
|
-
standaloneSchema: {};
|
|
36
|
-
response: {};
|
|
37
|
-
}>;
|
|
21
|
+
}, {}, import("elysia").DefaultEphemeral, import("elysia").DefaultEphemeral>;
|
|
38
22
|
export {};
|
|
@@ -5,5 +5,5 @@ export declare function isSuccessfulMutationResponse(ctx: Pick<Context, "set"> &
|
|
|
5
5
|
response?: unknown;
|
|
6
6
|
}): boolean;
|
|
7
7
|
export declare function appendPendingInvalidationHeader(set: Context["set"]): string[];
|
|
8
|
-
export declare function revalidateTag(tags: string | readonly string[]): boolean
|
|
9
|
-
export declare function runInvalidationRules(input: InvalidationInput): boolean
|
|
8
|
+
export declare function revalidateTag(tags: string | readonly string[]): Promise<boolean>;
|
|
9
|
+
export declare function runInvalidationRules(input: InvalidationInput): Promise<boolean>;
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
export declare function registerBrowserEventConnection(server: Bun.Server<unknown>, close: () => void): void;
|
|
2
|
+
export declare function unregisterBrowserEventConnection(server: Bun.Server<unknown>, close: () => void): void;
|
|
3
|
+
export declare function closeBrowserEventConnections(server: Bun.Server<unknown>): void;
|
|
@@ -13,7 +13,7 @@ export declare function callCachePurger(paths: string[]): void;
|
|
|
13
13
|
* instance's invalidation runs inside its own scope so cache `onDelete` hooks
|
|
14
14
|
* (auto-invalidate unregistration) hit the owning instance's registry.
|
|
15
15
|
*/
|
|
16
|
-
export declare function revalidatePath(path: string, type: RevalidateType): boolean
|
|
16
|
+
export declare function revalidatePath(path: string, type: RevalidateType): Promise<boolean>;
|
|
17
17
|
/**
|
|
18
18
|
* Invalidates `path` against a SINGLE instance's caches. `revalidateTag` uses
|
|
19
19
|
* this because it knows which instance registered each path — the cross-app
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { type FurinInstance } from "../instance.ts";
|
|
2
|
+
import type { PageCacheAdapter } from "./page-cache.ts";
|
|
3
|
+
export declare function getPageCacheAdapter(instance?: FurinInstance): PageCacheAdapter | undefined;
|
|
4
|
+
export declare function setPageCacheAdapter(instance: FurinInstance, adapter: PageCacheAdapter): void;
|
|
5
|
+
export declare function resetPageCacheAdapter(instance: FurinInstance): void;
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
export type PageCacheMode = "isr" | "ppr" | "ssg";
|
|
2
|
+
export interface PageCacheIdentity {
|
|
3
|
+
buildId: string;
|
|
4
|
+
key: string;
|
|
5
|
+
mode: PageCacheMode;
|
|
6
|
+
path: string;
|
|
7
|
+
scope: string;
|
|
8
|
+
tags: readonly string[];
|
|
9
|
+
}
|
|
10
|
+
export interface PageCacheEntry {
|
|
11
|
+
cachedAt: number;
|
|
12
|
+
payload: string;
|
|
13
|
+
revalidate: number | null;
|
|
14
|
+
}
|
|
15
|
+
export interface PageCacheLease {
|
|
16
|
+
expiresAt: number;
|
|
17
|
+
fence: number;
|
|
18
|
+
id: string;
|
|
19
|
+
revision: string;
|
|
20
|
+
}
|
|
21
|
+
export type PageCacheInvalidation = {
|
|
22
|
+
kind: "path";
|
|
23
|
+
path: string;
|
|
24
|
+
scope: string;
|
|
25
|
+
type: "layout" | "page";
|
|
26
|
+
} | {
|
|
27
|
+
kind: "tags";
|
|
28
|
+
scope: string;
|
|
29
|
+
tags: readonly string[];
|
|
30
|
+
};
|
|
31
|
+
export interface PageCacheInvalidationResult {
|
|
32
|
+
invalidated: boolean;
|
|
33
|
+
paths: readonly string[];
|
|
34
|
+
}
|
|
35
|
+
export interface PageCacheAdapter {
|
|
36
|
+
acquire: (input: {
|
|
37
|
+
identity: PageCacheIdentity;
|
|
38
|
+
leaseMs: number;
|
|
39
|
+
}) => Promise<PageCacheLease | null>;
|
|
40
|
+
commit: (input: {
|
|
41
|
+
entry: PageCacheEntry;
|
|
42
|
+
identity: PageCacheIdentity;
|
|
43
|
+
lease: PageCacheLease;
|
|
44
|
+
}) => Promise<"stored" | "superseded">;
|
|
45
|
+
invalidate: (input: PageCacheInvalidation) => Promise<PageCacheInvalidationResult>;
|
|
46
|
+
read: (identity: PageCacheIdentity) => Promise<PageCacheEntry | null>;
|
|
47
|
+
release: (input: {
|
|
48
|
+
identity: PageCacheIdentity;
|
|
49
|
+
lease: PageCacheLease;
|
|
50
|
+
}) => Promise<void>;
|
|
51
|
+
}
|
|
52
|
+
export declare function waitForPageCacheEntry(adapter: PageCacheAdapter, identity: PageCacheIdentity, timeoutMs: number): Promise<PageCacheEntry | null>;
|
|
53
|
+
export declare function createMemoryPageCache(): PageCacheAdapter;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import type { RedisClient } from "bun";
|
|
2
|
+
import type { PageCacheAdapter, PageCacheEntry, PageCacheIdentity, PageCacheLease } from "../page-cache.ts";
|
|
3
|
+
export interface RedisPageCacheOptions {
|
|
4
|
+
client: RedisClient;
|
|
5
|
+
namespace: string;
|
|
6
|
+
retentionMs?: number;
|
|
7
|
+
}
|
|
8
|
+
export declare class RedisPageCache implements PageCacheAdapter {
|
|
9
|
+
private readonly client;
|
|
10
|
+
private readonly metadataRetentionMs;
|
|
11
|
+
private readonly prefix;
|
|
12
|
+
private readonly retentionMs;
|
|
13
|
+
constructor(options: RedisPageCacheOptions);
|
|
14
|
+
acquire({ identity, leaseMs, }: {
|
|
15
|
+
identity: PageCacheIdentity;
|
|
16
|
+
leaseMs: number;
|
|
17
|
+
}): Promise<PageCacheLease | null>;
|
|
18
|
+
commit({ entry, identity, lease, }: {
|
|
19
|
+
entry: PageCacheEntry;
|
|
20
|
+
identity: PageCacheIdentity;
|
|
21
|
+
lease: PageCacheLease;
|
|
22
|
+
}): Promise<"stored" | "superseded">;
|
|
23
|
+
invalidate(input: Parameters<PageCacheAdapter["invalidate"]>[0]): Promise<{
|
|
24
|
+
invalidated: boolean;
|
|
25
|
+
paths: string[];
|
|
26
|
+
}>;
|
|
27
|
+
read(identity: PageCacheIdentity): Promise<PageCacheEntry | null>;
|
|
28
|
+
release({ identity, lease, }: {
|
|
29
|
+
identity: PageCacheIdentity;
|
|
30
|
+
lease: PageCacheLease;
|
|
31
|
+
}): Promise<void>;
|
|
32
|
+
private entryKey;
|
|
33
|
+
private fenceKey;
|
|
34
|
+
private leaseKey;
|
|
35
|
+
private pathsKey;
|
|
36
|
+
private leasesKey;
|
|
37
|
+
private tagPathsKey;
|
|
38
|
+
private tagLeasesKey;
|
|
39
|
+
private versionsKey;
|
|
40
|
+
}
|
|
41
|
+
export declare function redisPageCache(options: RedisPageCacheOptions): PageCacheAdapter;
|