@teyik0/furin 0.5.0-alpha.2 → 0.6.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/adapter/runtime-build.d.ts +2 -0
- package/dist/build/entry-template.d.ts +2 -0
- package/dist/build/entry-template.ts +2 -0
- package/dist/build/index.js +8082 -6573
- package/dist/build/request-keys.d.ts +4 -0
- package/dist/cli/index.js +8071 -6562
- package/dist/client/browser-events-runtime.d.ts +2 -1
- package/dist/client/define-route.d.ts +0 -1
- package/dist/client/dev-error-overlay.ts +1 -0
- package/dist/client/document.d.ts +1 -0
- package/dist/client/hmr.d.ts +1 -1
- package/dist/client/link.js +101 -61
- package/dist/client.js +13 -8
- package/dist/define-route.d.ts +163 -101
- package/dist/furin.d.ts +3 -0
- package/dist/furin.js +7663 -6480
- package/dist/plugin/index.js +462 -127
- package/dist/plugin/transform-dev-page.d.ts +7 -0
- package/dist/server/auto-invalidate/registry.d.ts +4 -2
- package/dist/server/browser-events/plugin.d.ts +3 -0
- package/dist/server/dev/runtime.production.d.ts +1 -0
- package/dist/server/dev-page-plugin.d.ts +1 -0
- package/dist/server/internal.d.ts +2 -0
- package/dist/server/internal.js +67 -39
- package/dist/server/production-server.js +66 -38
- package/dist/server/render/assemble.d.ts +6 -6
- package/dist/server/render/document.d.ts +1 -1
- package/dist/server/render/element.d.ts +1 -1
- package/dist/server/render/loaders.d.ts +11 -3
- package/dist/server/render/mixed-cache.d.ts +6 -0
- package/dist/server/render/ssr.d.ts +3 -3
- package/dist/server/router/discovery.d.ts +1 -0
- package/dist/server/router/patterns.d.ts +3 -0
- package/dist/server/router/plugin.d.ts +3 -0
- package/dist/server/router/types.d.ts +4 -0
- package/dist/server/security/csp.d.ts +12 -0
- package/dist/server/sync/index.js +65 -37
- package/dist/server/sync/postgres/index.js +8 -0
- package/package.json +12 -11
- package/src/adapter/README.md +3 -0
- package/src/adapter/bun.ts +3 -0
- package/src/adapter/package.ts +4 -0
- package/src/adapter/runtime-build.ts +36 -2
- package/src/adapter/static.ts +10 -4
- package/src/adapter/vercel.ts +18 -10
- package/src/build/entry-template.ts +2 -0
- package/src/build/hydrate.ts +1 -0
- package/src/build/request-keys.ts +93 -0
- package/src/build/ssg-cache.ts +9 -4
- package/src/client/boundaries.tsx +1 -1
- package/src/client/browser-events-runtime.ts +69 -16
- package/src/client/define-route.ts +0 -1
- package/src/client/dev-error-overlay.ts +1 -0
- package/src/client/document.tsx +19 -2
- package/src/client/hmr.ts +3 -2
- package/src/client/router/boundary-tree.tsx +3 -4
- package/src/client/router/provider.tsx +109 -61
- package/src/define-route.ts +356 -127
- package/src/furin.ts +138 -25
- package/src/plugin/route-config-autofix.ts +2 -2
- package/src/plugin/routes.ts +16 -5
- package/src/plugin/transform-dev-page.ts +231 -0
- package/src/rsc/version.ts +5 -0
- package/src/server/auto-invalidate/registry.ts +53 -25
- package/src/server/browser-events/plugin.ts +112 -1
- package/src/server/cache/dev-loader.ts +1 -1
- package/src/server/cache/invalidation.ts +2 -0
- package/src/server/cache/isr-ssg.ts +1 -1
- package/src/server/cache/ssg.ts +1 -1
- package/src/server/dev/diagnostics.ts +4 -2
- package/src/server/dev/error.ts +2 -1
- package/src/server/dev/graph.ts +55 -6
- package/src/server/dev/runtime.production.ts +4 -0
- package/src/server/dev/symbolicate.ts +2 -0
- package/src/server/dev-page-plugin.ts +67 -4
- package/src/server/evlog.ts +1 -1
- package/src/server/internal.ts +2 -0
- package/src/server/render/assemble.ts +15 -11
- package/src/server/render/document.tsx +3 -1
- package/src/server/render/element.tsx +5 -5
- package/src/server/render/isr.ts +11 -5
- package/src/server/render/loaders.ts +243 -56
- package/src/server/render/mixed-cache.ts +298 -0
- package/src/server/render/not-found.ts +10 -4
- package/src/server/render/ppr-document.ts +45 -10
- package/src/server/render/ppr-route.ts +26 -12
- package/src/server/render/ssg.ts +2 -1
- package/src/server/render/ssr.ts +55 -31
- package/src/server/render/static-params.ts +1 -1
- package/src/server/router/discovery.ts +14 -0
- package/src/server/router/hmr.ts +106 -16
- package/src/server/router/patterns.ts +27 -0
- package/src/server/router/plugin.ts +69 -9
- package/src/server/router/source-version.ts +20 -2
- package/src/server/router/types.ts +4 -0
- package/src/server/security/csp.ts +44 -0
- package/src/server/sync/postgres/index.ts +8 -0
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { Context } from "elysia";
|
|
2
|
+
import type { RuntimePage, RuntimeRoute } from "../../client/internal/runtime-types.ts";
|
|
3
|
+
import { type FurinInstance } from "../instance.ts";
|
|
4
|
+
import type { ResolvedRoute } from "../router/types.ts";
|
|
5
|
+
export declare function clearMixedPublicCache(instance?: FurinInstance): void;
|
|
6
|
+
export declare function cacheMixedPublicLoader(route: ResolvedRoute, ctx: Context, segment: RuntimeRoute | RuntimePage, index: number, parentData: Promise<Record<string, unknown>>, parentFieldsRead: ReadonlySet<string>, run: () => Promise<Record<string, unknown>>): Promise<Record<string, unknown>>;
|
|
@@ -84,7 +84,7 @@ interface ShellFallbackResult {
|
|
|
84
84
|
* to a string) — both start from this same React stream and only diverge in how
|
|
85
85
|
* they consume it and which fields they log.
|
|
86
86
|
*/
|
|
87
|
-
export declare function renderElementWithShellFallback(element: ReactNode, errorComponent: Parameters<typeof buildErrorElement>[0], ssrContext: RouterContextValue, wrapFallbackDocument: (element: ReactNode, digest: string, message: string) => ReactNode): Promise<ShellFallbackResult>;
|
|
87
|
+
export declare function renderElementWithShellFallback(element: ReactNode, errorComponent: Parameters<typeof buildErrorElement>[0], ssrContext: RouterContextValue, wrapFallbackDocument: (element: ReactNode, digest: string, message: string) => ReactNode, nonce?: string): Promise<ShellFallbackResult>;
|
|
88
88
|
/**
|
|
89
89
|
* defer() streams data progressively — it only makes sense in SSR. In SSG/ISR
|
|
90
90
|
* the HTML is pre-rendered and cached, so the deferred fields would be absent
|
|
@@ -108,8 +108,8 @@ interface SsrTransportScripts {
|
|
|
108
108
|
usesRouteFrames: boolean;
|
|
109
109
|
}
|
|
110
110
|
export declare function injectAfterEntry(html: string, injection: string, fallbackIndex: number, hasEntryModule: boolean): string | undefined;
|
|
111
|
-
export declare function buildSsrTransportScripts(dataPayload: Record<string, unknown>, deferredKeys: string[], hasDeferred: boolean, shellErrored: boolean): SsrTransportScripts;
|
|
112
|
-
export declare function writeDeferredSsrChunks(writer: WritableStreamDefaultWriter<Uint8Array>, enc: TextEncoder, deferredPromises: Record<string, Promise<unknown>>, usesRouteFrames: boolean): Promise<void>;
|
|
111
|
+
export declare function buildSsrTransportScripts(dataPayload: Record<string, unknown>, deferredKeys: string[], hasDeferred: boolean, shellErrored: boolean, nonce?: string): SsrTransportScripts;
|
|
112
|
+
export declare function writeDeferredSsrChunks(writer: WritableStreamDefaultWriter<Uint8Array>, enc: TextEncoder, deferredPromises: Record<string, Promise<unknown>>, usesRouteFrames: boolean, nonce?: string): Promise<void>;
|
|
113
113
|
/**
|
|
114
114
|
* Serialises a loader's `syncData` + `deferredPromises` into the same one-line
|
|
115
115
|
* NDJSON shape the live `/_furin/data` endpoint emits.
|
|
@@ -2,6 +2,7 @@ import type { RuntimePage, RuntimeRoute } from "../../client/internal/runtime-ty
|
|
|
2
2
|
import { type CompileContext } from "../internal.ts";
|
|
3
3
|
import type { ResolvedRoute, RootLayout } from "./types.ts";
|
|
4
4
|
export declare function isModuleNotFoundError(err: unknown): boolean;
|
|
5
|
+
export declare function annotateScannedRequestKeys(routes: ResolvedRoute[]): Promise<void>;
|
|
5
6
|
/** @internal Exported for unit testing. */
|
|
6
7
|
export declare function collectRouteTags(routeChain: RuntimeRoute[], page: Pick<RuntimePage, "tags"> | undefined): string[] | undefined;
|
|
7
8
|
export declare function loadProdRoutes(ctx: CompileContext): {
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import type { RuntimePage, RuntimeRoute } from "../../client/internal/runtime-types.ts";
|
|
2
|
+
import type { ResolvedRoute } from "./types.ts";
|
|
2
3
|
export declare function collectIntermediateLayoutDirs(pagePath: string, rootPath: string): string[];
|
|
3
4
|
export declare function resolveRouteRevalidate(page: RuntimePage): number | undefined;
|
|
5
|
+
export declare function resolveDocumentMode(route: ResolvedRoute): "ssr" | "ssg" | "isr";
|
|
6
|
+
export declare function resolveDocumentRevalidate(route: ResolvedRoute): number | undefined;
|
|
4
7
|
export declare function resolveMode(page: RuntimePage, routeChain: RuntimeRoute[]): "ssr" | "ssg" | "isr";
|
|
5
8
|
export interface DynamicRouteSegment {
|
|
6
9
|
catchAll: boolean;
|
|
@@ -6,6 +6,9 @@ type RefreshDevRoute = (route: ResolvedRoute) => Promise<{
|
|
|
6
6
|
route: ResolvedRoute;
|
|
7
7
|
root: RootLayout;
|
|
8
8
|
}>;
|
|
9
|
+
export declare function serializeGuardRedirect(response: Response, request: Request): Promise<Response>;
|
|
10
|
+
/** Serialise navigation data after Elysia has run the matched page's hooks. */
|
|
11
|
+
export declare function renderRouteData(route: ResolvedRoute, ctx: Context, root: RootLayout, searchRoutes: SearchRouteMetadata[], logicalHref: string): Promise<Response>;
|
|
9
12
|
export declare function createRoutePlugin(route: ResolvedRoute, root: RootLayout, buildId?: string, searchRoutes?: SearchRouteMetadata[]): AnyElysia;
|
|
10
13
|
export declare function renderResolvedRoute(route: ResolvedRoute, ctx: Context, root: RootLayout, buildId: string, searchRoutes: SearchRouteMetadata[] | undefined): unknown;
|
|
11
14
|
/**
|
|
@@ -39,6 +39,10 @@ export interface ResolvedRoute {
|
|
|
39
39
|
page: RuntimePage;
|
|
40
40
|
path: string;
|
|
41
41
|
pattern: string;
|
|
42
|
+
/** Finite private field names inferred from the request loaders in this chain. */
|
|
43
|
+
requestKeys?: string[];
|
|
44
|
+
/** Request field names for each entry in routeChain, in the same order. */
|
|
45
|
+
requestKeysByLoader?: string[][];
|
|
42
46
|
routeChain: RuntimeRoute[];
|
|
43
47
|
/**
|
|
44
48
|
* Per-directory boundary chain, ordered shallow → deep. Only directories
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Elysia } from "elysia";
|
|
2
|
+
export interface FurinCspOptions {
|
|
3
|
+
policy: (nonce: string | undefined) => string;
|
|
4
|
+
reportOnly?: boolean;
|
|
5
|
+
}
|
|
6
|
+
/** @internal Called only by live SSR, never by public SSG/ISR prerenders. */
|
|
7
|
+
export declare function useRequestCspNonce(request: Request): string | undefined;
|
|
8
|
+
/** Install before Furin routes to attach an application-owned CSP to HTML responses. */
|
|
9
|
+
export declare function furinCsp({ policy, reportOnly }: FurinCspOptions): Elysia<"", "local", import("elysia").DefaultSingleton, {
|
|
10
|
+
typebox: {};
|
|
11
|
+
error: [];
|
|
12
|
+
}, import("elysia").DefaultMetadata, {}, import("elysia").DefaultEphemeral, import("elysia").DefaultEphemeral>;
|
|
@@ -194,7 +194,7 @@ class PollingSyncNotifier {
|
|
|
194
194
|
}
|
|
195
195
|
}
|
|
196
196
|
|
|
197
|
-
// ../../node_modules/.bun/evlog@2.29.0+
|
|
197
|
+
// ../../node_modules/.bun/evlog@2.29.0+dbd53f8719b7cf53/node_modules/evlog/dist/utils.mjs
|
|
198
198
|
function elapsedMs(startTime) {
|
|
199
199
|
return Math.max(0, Date.now() - startTime);
|
|
200
200
|
}
|
|
@@ -335,7 +335,7 @@ var init_utils = __esm(() => {
|
|
|
335
335
|
_isoDate = /* @__PURE__ */ new Date;
|
|
336
336
|
});
|
|
337
337
|
|
|
338
|
-
// ../../node_modules/.bun/evlog@2.29.0+
|
|
338
|
+
// ../../node_modules/.bun/evlog@2.29.0+dbd53f8719b7cf53/node_modules/evlog/dist/redact-C7FmdhwI.mjs
|
|
339
339
|
function normalizeRedactPathPattern(pattern) {
|
|
340
340
|
if (!pattern.includes("*") && !pattern.includes("."))
|
|
341
341
|
return `**.${pattern}`;
|
|
@@ -644,7 +644,7 @@ var init_redact_C7FmdhwI = __esm(() => {
|
|
|
644
644
|
globallyRedacted = Symbol.for("evlog.globallyRedacted");
|
|
645
645
|
});
|
|
646
646
|
|
|
647
|
-
// ../../node_modules/.bun/evlog@2.29.0+
|
|
647
|
+
// ../../node_modules/.bun/evlog@2.29.0+dbd53f8719b7cf53/node_modules/evlog/dist/globalRegistry-Bh3bIGwA.mjs
|
|
648
648
|
function logPluginError(name, hook, err) {
|
|
649
649
|
console.error(`[evlog/${name}] ${hook} failed:`, err);
|
|
650
650
|
}
|
|
@@ -814,7 +814,7 @@ var init_globalRegistry_Bh3bIGwA = __esm(() => {
|
|
|
814
814
|
globalConfig = getRegistry().config;
|
|
815
815
|
});
|
|
816
816
|
|
|
817
|
-
// ../../node_modules/.bun/evlog@2.29.0+
|
|
817
|
+
// ../../node_modules/.bun/evlog@2.29.0+dbd53f8719b7cf53/node_modules/evlog/dist/pretty-error-D8rlWNL1.mjs
|
|
818
818
|
function pushTreeSpacer(children) {
|
|
819
819
|
children.push(PRETTY_ERROR_TREE_SPACER);
|
|
820
820
|
}
|
|
@@ -1115,7 +1115,7 @@ var init_pretty_error_D8rlWNL1 = __esm(() => {
|
|
|
1115
1115
|
SKIP_FRAME_FN_RE = /^(?:createError|EvlogError|new EvlogError)$/;
|
|
1116
1116
|
});
|
|
1117
1117
|
|
|
1118
|
-
// ../../node_modules/.bun/evlog@2.29.0+
|
|
1118
|
+
// ../../node_modules/.bun/evlog@2.29.0+dbd53f8719b7cf53/node_modules/evlog/dist/dev-terminal-Brarc6vc.mjs
|
|
1119
1119
|
function finalizePrettyError(partial, frameworkOverlay, pretty, inDev) {
|
|
1120
1120
|
const compact = partial.compact ?? (inDev && pretty);
|
|
1121
1121
|
const detail = partial.detail ?? (frameworkOverlay ? "guidance" : "full");
|
|
@@ -1168,7 +1168,7 @@ var init_dev_terminal_Brarc6vc = __esm(() => {
|
|
|
1168
1168
|
};
|
|
1169
1169
|
});
|
|
1170
1170
|
|
|
1171
|
-
// ../../node_modules/.bun/evlog@2.29.0+
|
|
1171
|
+
// ../../node_modules/.bun/evlog@2.29.0+dbd53f8719b7cf53/node_modules/evlog/dist/wideEventChannel-BUDW48oP.mjs
|
|
1172
1172
|
function hasWideEventPublisher() {
|
|
1173
1173
|
return publisher !== null;
|
|
1174
1174
|
}
|
|
@@ -1184,7 +1184,7 @@ function publishWideEvent(event) {
|
|
|
1184
1184
|
var publisher = null;
|
|
1185
1185
|
var init_wideEventChannel_BUDW48oP = () => {};
|
|
1186
1186
|
|
|
1187
|
-
// ../../node_modules/.bun/evlog@2.29.0+
|
|
1187
|
+
// ../../node_modules/.bun/evlog@2.29.0+dbd53f8719b7cf53/node_modules/evlog/dist/error-brand-D0-DCPvr.mjs
|
|
1188
1188
|
function isEvlogError(error) {
|
|
1189
1189
|
return typeof error === "object" && error !== null && error[evlogErrorBrand] === true;
|
|
1190
1190
|
}
|
|
@@ -1193,7 +1193,7 @@ var init_error_brand_D0_DCPvr = __esm(() => {
|
|
|
1193
1193
|
evlogErrorBrand = Symbol.for("evlog.error.brand");
|
|
1194
1194
|
});
|
|
1195
1195
|
|
|
1196
|
-
// ../../node_modules/.bun/evlog@2.29.0+
|
|
1196
|
+
// ../../node_modules/.bun/evlog@2.29.0+dbd53f8719b7cf53/node_modules/evlog/dist/error.mjs
|
|
1197
1197
|
var evlogErrorInternalKey, evlogErrorDataKey, EvlogError;
|
|
1198
1198
|
var init_error = __esm(() => {
|
|
1199
1199
|
init_utils();
|
|
@@ -1302,7 +1302,7 @@ var init_error = __esm(() => {
|
|
|
1302
1302
|
});
|
|
1303
1303
|
});
|
|
1304
1304
|
|
|
1305
|
-
// ../../node_modules/.bun/evlog@2.29.0+
|
|
1305
|
+
// ../../node_modules/.bun/evlog@2.29.0+dbd53f8719b7cf53/node_modules/evlog/dist/headers-Bx1ieR-m.mjs
|
|
1306
1306
|
function extractSafeHeaders(headers) {
|
|
1307
1307
|
const raw = {};
|
|
1308
1308
|
headers.forEach((value, key) => {
|
|
@@ -1323,7 +1323,7 @@ var init_headers_Bx1ieR_m = __esm(() => {
|
|
|
1323
1323
|
init_utils();
|
|
1324
1324
|
});
|
|
1325
1325
|
|
|
1326
|
-
// ../../node_modules/.bun/evlog@2.29.0+
|
|
1326
|
+
// ../../node_modules/.bun/evlog@2.29.0+dbd53f8719b7cf53/node_modules/evlog/dist/audit-C8euLMvu.mjs
|
|
1327
1327
|
function writePrettyStdout(text) {
|
|
1328
1328
|
(globalThis.__evlogNativeStdoutWrite ?? nativeStdoutWrite)?.(text);
|
|
1329
1329
|
}
|
|
@@ -2245,12 +2245,12 @@ var init_audit_C8euLMvu = __esm(() => {
|
|
|
2245
2245
|
initLogger(__EVLOG_CONFIG__);
|
|
2246
2246
|
});
|
|
2247
2247
|
|
|
2248
|
-
// ../../node_modules/.bun/evlog@2.29.0+
|
|
2248
|
+
// ../../node_modules/.bun/evlog@2.29.0+dbd53f8719b7cf53/node_modules/evlog/dist/index.mjs
|
|
2249
2249
|
var init_dist = __esm(() => {
|
|
2250
2250
|
init_audit_C8euLMvu();
|
|
2251
2251
|
});
|
|
2252
2252
|
|
|
2253
|
-
// ../../node_modules/.bun/evlog@2.29.0+
|
|
2253
|
+
// ../../node_modules/.bun/evlog@2.29.0+dbd53f8719b7cf53/node_modules/evlog/dist/streamResponse-OlirMA5P.mjs
|
|
2254
2254
|
function shouldDeferEmitForResponse(response) {
|
|
2255
2255
|
if (!response.body)
|
|
2256
2256
|
return false;
|
|
@@ -2330,7 +2330,7 @@ function bindStreamingResponseLifecycle(response, onComplete) {
|
|
|
2330
2330
|
}
|
|
2331
2331
|
var init_streamResponse_OlirMA5P = () => {};
|
|
2332
2332
|
|
|
2333
|
-
// ../../node_modules/.bun/evlog@2.29.0+
|
|
2333
|
+
// ../../node_modules/.bun/evlog@2.29.0+dbd53f8719b7cf53/node_modules/evlog/dist/errors-CL8dDgIi.mjs
|
|
2334
2334
|
function extractErrorStatus(error) {
|
|
2335
2335
|
if (error === null || typeof error !== "object")
|
|
2336
2336
|
return 500;
|
|
@@ -2340,7 +2340,7 @@ function extractErrorStatus(error) {
|
|
|
2340
2340
|
}
|
|
2341
2341
|
var init_errors_CL8dDgIi = () => {};
|
|
2342
2342
|
|
|
2343
|
-
// ../../node_modules/.bun/evlog@2.29.0+
|
|
2343
|
+
// ../../node_modules/.bun/evlog@2.29.0+dbd53f8719b7cf53/node_modules/evlog/dist/deferred-drain-CfRYimo5.mjs
|
|
2344
2344
|
function shouldLog(path, include, exclude) {
|
|
2345
2345
|
if (exclude && exclude.length > 0) {
|
|
2346
2346
|
if (exclude.some((pattern) => matchesPattern(path, pattern)))
|
|
@@ -2368,7 +2368,7 @@ var init_deferred_drain_CfRYimo5 = __esm(() => {
|
|
|
2368
2368
|
init_utils();
|
|
2369
2369
|
});
|
|
2370
2370
|
|
|
2371
|
-
// ../../node_modules/.bun/evlog@2.29.0+
|
|
2371
|
+
// ../../node_modules/.bun/evlog@2.29.0+dbd53f8719b7cf53/node_modules/evlog/dist/middleware-fam3VyaL.mjs
|
|
2372
2372
|
function resolveMiddlewarePluginRunner(options) {
|
|
2373
2373
|
const global = getGlobalPluginRunner();
|
|
2374
2374
|
const local = options.plugins;
|
|
@@ -2563,7 +2563,7 @@ var init_middleware_fam3VyaL = __esm(() => {
|
|
|
2563
2563
|
runnerCache = /* @__PURE__ */ new WeakMap;
|
|
2564
2564
|
});
|
|
2565
2565
|
|
|
2566
|
-
// ../../node_modules/.bun/evlog@2.29.0+
|
|
2566
|
+
// ../../node_modules/.bun/evlog@2.29.0+dbd53f8719b7cf53/node_modules/evlog/dist/integration-CGD18W8r.mjs
|
|
2567
2567
|
function attachForkToLogger(storage, parent, middlewareOptions, lifecycle) {
|
|
2568
2568
|
const log = parent;
|
|
2569
2569
|
log.fork = (label, fn) => {
|
|
@@ -2666,7 +2666,7 @@ var init_integration_CGD18W8r = __esm(() => {
|
|
|
2666
2666
|
init_middleware_fam3VyaL();
|
|
2667
2667
|
});
|
|
2668
2668
|
|
|
2669
|
-
// ../../node_modules/.bun/evlog@2.29.0+
|
|
2669
|
+
// ../../node_modules/.bun/evlog@2.29.0+dbd53f8719b7cf53/node_modules/evlog/dist/toolkit/storage.mjs
|
|
2670
2670
|
import { AsyncLocalStorage as AsyncLocalStorage4 } from "async_hooks";
|
|
2671
2671
|
function createLoggerStorage(contextHint, id = contextHint) {
|
|
2672
2672
|
const storage = getSharedStorage(id, () => new AsyncLocalStorage4);
|
|
@@ -2685,7 +2685,7 @@ var init_storage = __esm(() => {
|
|
|
2685
2685
|
init_globalRegistry_Bh3bIGwA();
|
|
2686
2686
|
});
|
|
2687
2687
|
|
|
2688
|
-
// ../../node_modules/.bun/evlog@2.29.0+
|
|
2688
|
+
// ../../node_modules/.bun/evlog@2.29.0+dbd53f8719b7cf53/node_modules/evlog/dist/toolkit.mjs
|
|
2689
2689
|
var init_toolkit = __esm(() => {
|
|
2690
2690
|
init_integration_CGD18W8r();
|
|
2691
2691
|
init_storage();
|
|
@@ -2881,14 +2881,29 @@ init_instance();
|
|
|
2881
2881
|
|
|
2882
2882
|
class AutoInvalidateRegistry {
|
|
2883
2883
|
pathToTags = new Map;
|
|
2884
|
+
pathOwners = new Map;
|
|
2884
2885
|
tagToPaths = new Map;
|
|
2885
|
-
|
|
2886
|
-
|
|
2887
|
-
|
|
2886
|
+
reindexPath(urlPath) {
|
|
2887
|
+
const previous = this.pathToTags.get(urlPath);
|
|
2888
|
+
if (previous) {
|
|
2889
|
+
for (const tag of previous) {
|
|
2890
|
+
const paths = this.tagToPaths.get(tag);
|
|
2891
|
+
paths?.delete(urlPath);
|
|
2892
|
+
if (paths?.size === 0) {
|
|
2893
|
+
this.tagToPaths.delete(tag);
|
|
2894
|
+
}
|
|
2895
|
+
}
|
|
2896
|
+
}
|
|
2897
|
+
const uniqueTags = new Set;
|
|
2898
|
+
for (const tags of this.pathOwners.get(urlPath)?.values() ?? []) {
|
|
2899
|
+
for (const tag of tags) {
|
|
2900
|
+
uniqueTags.add(tag);
|
|
2901
|
+
}
|
|
2902
|
+
}
|
|
2903
|
+
if (uniqueTags.size === 0) {
|
|
2904
|
+
this.pathToTags.delete(urlPath);
|
|
2888
2905
|
return;
|
|
2889
2906
|
}
|
|
2890
|
-
this.unregisterPath(urlPath);
|
|
2891
|
-
const uniqueTags = new Set(tags);
|
|
2892
2907
|
this.pathToTags.set(urlPath, uniqueTags);
|
|
2893
2908
|
for (const tag of uniqueTags) {
|
|
2894
2909
|
let paths = this.tagToPaths.get(tag);
|
|
@@ -2899,6 +2914,23 @@ class AutoInvalidateRegistry {
|
|
|
2899
2914
|
paths.add(urlPath);
|
|
2900
2915
|
}
|
|
2901
2916
|
}
|
|
2917
|
+
registerLoaderTags(urlPath, tags, owner) {
|
|
2918
|
+
const ownerKey = owner ?? "default";
|
|
2919
|
+
let owners = this.pathOwners.get(urlPath);
|
|
2920
|
+
if (tags === undefined || tags.length === 0) {
|
|
2921
|
+
owners?.delete(ownerKey);
|
|
2922
|
+
if (owners?.size === 0) {
|
|
2923
|
+
this.pathOwners.delete(urlPath);
|
|
2924
|
+
}
|
|
2925
|
+
} else {
|
|
2926
|
+
if (!owners) {
|
|
2927
|
+
owners = new Map;
|
|
2928
|
+
this.pathOwners.set(urlPath, owners);
|
|
2929
|
+
}
|
|
2930
|
+
owners.set(ownerKey, new Set(tags));
|
|
2931
|
+
}
|
|
2932
|
+
this.reindexPath(urlPath);
|
|
2933
|
+
}
|
|
2902
2934
|
pathsForTags(tags) {
|
|
2903
2935
|
const paths = new Set;
|
|
2904
2936
|
for (const tag of tags) {
|
|
@@ -2908,25 +2940,21 @@ class AutoInvalidateRegistry {
|
|
|
2908
2940
|
}
|
|
2909
2941
|
return [...paths];
|
|
2910
2942
|
}
|
|
2911
|
-
unregisterPath(urlPath) {
|
|
2912
|
-
|
|
2913
|
-
|
|
2914
|
-
|
|
2915
|
-
|
|
2916
|
-
|
|
2917
|
-
|
|
2918
|
-
|
|
2919
|
-
continue;
|
|
2920
|
-
}
|
|
2921
|
-
paths.delete(urlPath);
|
|
2922
|
-
if (paths.size === 0) {
|
|
2923
|
-
this.tagToPaths.delete(tag);
|
|
2943
|
+
unregisterPath(urlPath, owner) {
|
|
2944
|
+
if (owner === undefined) {
|
|
2945
|
+
this.pathOwners.delete(urlPath);
|
|
2946
|
+
} else {
|
|
2947
|
+
const owners = this.pathOwners.get(urlPath);
|
|
2948
|
+
owners?.delete(owner);
|
|
2949
|
+
if (owners?.size === 0) {
|
|
2950
|
+
this.pathOwners.delete(urlPath);
|
|
2924
2951
|
}
|
|
2925
2952
|
}
|
|
2926
|
-
this.
|
|
2953
|
+
this.reindexPath(urlPath);
|
|
2927
2954
|
}
|
|
2928
2955
|
reset() {
|
|
2929
2956
|
this.pathToTags.clear();
|
|
2957
|
+
this.pathOwners.clear();
|
|
2930
2958
|
this.tagToPaths.clear();
|
|
2931
2959
|
}
|
|
2932
2960
|
}
|
|
@@ -5,6 +5,7 @@ var LEASE_MS = 30000;
|
|
|
5
5
|
var MUTATION_TTL_MS = 24 * 60 * 60 * 1000;
|
|
6
6
|
var RECOVERY_RETRY_INITIAL_MS = 250;
|
|
7
7
|
var RECOVERY_RETRY_MAX_MS = 32000;
|
|
8
|
+
var CURSOR_CHECK_INTERVAL_MS = 15000;
|
|
8
9
|
var UNSIGNED_INTEGER_PATTERN = /^\d+$/;
|
|
9
10
|
function notificationChannel(namespace) {
|
|
10
11
|
const digest = new Bun.CryptoHasher("sha256").update(namespace).digest("hex");
|
|
@@ -324,9 +325,16 @@ class PostgresSyncNotifier {
|
|
|
324
325
|
});
|
|
325
326
|
};
|
|
326
327
|
const subscription = await this.sql.listen(this.notificationChannel, emit, recover);
|
|
328
|
+
const cursorCheck = setInterval(() => {
|
|
329
|
+
if (!retry) {
|
|
330
|
+
recover();
|
|
331
|
+
}
|
|
332
|
+
}, CURSOR_CHECK_INTERVAL_MS);
|
|
333
|
+
cursorCheck.unref?.();
|
|
327
334
|
return {
|
|
328
335
|
unsubscribe: () => {
|
|
329
336
|
active = false;
|
|
337
|
+
clearInterval(cursorCheck);
|
|
330
338
|
if (retry) {
|
|
331
339
|
clearTimeout(retry);
|
|
332
340
|
retry = undefined;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@teyik0/furin",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.0-alpha.1",
|
|
4
4
|
"description": "React meta-framework powered by Elysia and Bun with file-based routing, SSR, SSG, and ISR.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"react",
|
|
@@ -156,25 +156,26 @@
|
|
|
156
156
|
"dependencies": {
|
|
157
157
|
"@elysia/static": "2.0.0-beta.2",
|
|
158
158
|
"@jridgewell/trace-mapping": "^0.3.31",
|
|
159
|
-
"@vercel/functions": "^3.9.
|
|
160
|
-
"@yuku-toolchain/types": "0.
|
|
159
|
+
"@vercel/functions": "^3.9.9",
|
|
160
|
+
"@yuku-toolchain/types": "0.12.0",
|
|
161
161
|
"exact-mirror": "1.2.6",
|
|
162
|
-
"magic-string": "^1.2
|
|
163
|
-
"react-server-dom-webpack": "19.
|
|
162
|
+
"magic-string": "^1.4.2",
|
|
163
|
+
"react-server-dom-webpack": "19.3.0",
|
|
164
164
|
"seroval": "^1.6.7",
|
|
165
|
-
"
|
|
166
|
-
"yuku-
|
|
165
|
+
"typescript": "7.0.2",
|
|
166
|
+
"yuku-ast": "0.12.0",
|
|
167
|
+
"yuku-parser": "0.12.0"
|
|
167
168
|
},
|
|
168
169
|
"devDependencies": {
|
|
169
|
-
"@types/react": "^19.
|
|
170
|
-
"@types/react-dom": "^19.
|
|
170
|
+
"@types/react": "^19.3.0",
|
|
171
|
+
"@types/react-dom": "^19.3.0",
|
|
171
172
|
"expect-type": "^1.4.0"
|
|
172
173
|
},
|
|
173
174
|
"peerDependencies": {
|
|
174
175
|
"elysia": "2.0.0-beta.19",
|
|
175
176
|
"evlog": "^2.29.0",
|
|
176
|
-
"react": "19.
|
|
177
|
-
"react-dom": "19.
|
|
177
|
+
"react": "19.3.0",
|
|
178
|
+
"react-dom": "19.3.0",
|
|
178
179
|
"typebox": "1.3.34"
|
|
179
180
|
},
|
|
180
181
|
"engines": {
|
package/src/adapter/README.md
CHANGED
|
@@ -33,6 +33,9 @@ and keeps background ISR work alive with `waitUntil`.
|
|
|
33
33
|
The Function bundle uses the same Elysia AOT capture path with the Bun target.
|
|
34
34
|
No custom Elysia runtime adapter is needed: Vercel invokes the application's
|
|
35
35
|
Web-standard `handle(Request)` API inside its Bun runtime.
|
|
36
|
+
For Furin Sync, the Vercel target streams browser cursor notifications through
|
|
37
|
+
Server-Sent Events at `/_furin/events`. Bun servers keep the WebSocket transport.
|
|
38
|
+
Both transports use the durable sync recovery endpoint after reconnects (`/_furin/sync/changes` by default, configurable with `sync.path`).
|
|
36
39
|
|
|
37
40
|
Vercel Prerender Function invocations bypass Furin's process-local SSG/ISR
|
|
38
41
|
cache. The CDN owns freshness and each regeneration returns newly rendered
|
package/src/adapter/bun.ts
CHANGED
|
@@ -17,6 +17,7 @@ import { environmentGuardPlugin } from "../rsc/build/environment.ts";
|
|
|
17
17
|
import { clientDirNameForPrefix } from "../shared/prefix.ts";
|
|
18
18
|
import {
|
|
19
19
|
buildRuntimeAppsSequentially,
|
|
20
|
+
mixedRuntimePlugin,
|
|
20
21
|
pprRuntimePlugin,
|
|
21
22
|
type RuntimeTargetApp,
|
|
22
23
|
} from "./runtime-build.ts";
|
|
@@ -223,6 +224,7 @@ export async function buildBunTarget(
|
|
|
223
224
|
entry.plugin,
|
|
224
225
|
productionInstrumentationPlugin(),
|
|
225
226
|
pprRuntimePlugin(apps),
|
|
227
|
+
mixedRuntimePlugin(apps),
|
|
226
228
|
...(options.plugins ?? []),
|
|
227
229
|
createRoutesPlugin({ instances: apps, target: "server" }),
|
|
228
230
|
isomorphicTransformPlugin("server"),
|
|
@@ -257,6 +259,7 @@ export async function buildBunTarget(
|
|
|
257
259
|
entry.plugin,
|
|
258
260
|
productionInstrumentationPlugin(),
|
|
259
261
|
pprRuntimePlugin(apps),
|
|
262
|
+
mixedRuntimePlugin(apps),
|
|
260
263
|
...(options.plugins ?? []),
|
|
261
264
|
createRoutesPlugin({ instances: apps, target: "server" }),
|
|
262
265
|
isomorphicTransformPlugin("server"),
|
package/src/adapter/package.ts
CHANGED
|
@@ -110,6 +110,8 @@ export async function buildPackageTarget(
|
|
|
110
110
|
const routeMetadata: Record<
|
|
111
111
|
string,
|
|
112
112
|
{
|
|
113
|
+
requestKeys?: string[];
|
|
114
|
+
requestKeysByLoader?: string[][];
|
|
113
115
|
segmentBoundaries: Array<{
|
|
114
116
|
depth: number;
|
|
115
117
|
path: string;
|
|
@@ -120,6 +122,8 @@ export async function buildPackageTarget(
|
|
|
120
122
|
> = {};
|
|
121
123
|
for (const route of routes) {
|
|
122
124
|
routeMetadata[toPosixPath(route.path)] = {
|
|
125
|
+
requestKeys: route.requestKeys,
|
|
126
|
+
requestKeysByLoader: route.requestKeysByLoader,
|
|
123
127
|
segmentBoundaries: route.segmentBoundaries.map((b) => ({
|
|
124
128
|
depth: b.depth,
|
|
125
129
|
errorPath: b.errorPath ? toPosixPath(b.errorPath) : undefined,
|
|
@@ -14,9 +14,10 @@ import type { BuildAppOptions } from "../build/types.ts";
|
|
|
14
14
|
import { composableRouteModuleSpecifier, routeSourcePaths } from "../plugin/routes.ts";
|
|
15
15
|
import { buildRscGraph } from "../rsc/build/index.ts";
|
|
16
16
|
import { ssgRouteCache } from "../server/cache/ssg.ts";
|
|
17
|
-
import { hasRequestLoader } from "../server/render/loaders.ts";
|
|
17
|
+
import { hasMixedLoaderModes, hasRequestLoader } from "../server/render/loaders.ts";
|
|
18
18
|
import { generateProdIndexHtml } from "../server/render/shell.ts";
|
|
19
19
|
import { setProductionTemplateContent } from "../server/render/template.ts";
|
|
20
|
+
import { resolveDocumentMode } from "../server/router/patterns.ts";
|
|
20
21
|
import type { ResolvedRoute, RootLayout } from "../server/router/types.ts";
|
|
21
22
|
import { clientDirNameForPrefix } from "../shared/prefix.ts";
|
|
22
23
|
|
|
@@ -35,18 +36,21 @@ const _pkgSrcDir = existsSync(join(_pkgRoot, "src", "furin.ts"))
|
|
|
35
36
|
// copy would point at files that don't exist and silently weaken the build ID.
|
|
36
37
|
const _ext = ".ts";
|
|
37
38
|
const PPR_ROUTE_IMPORT_RE = /ppr-route(?:\.ts)?$/;
|
|
39
|
+
const MIXED_CACHE_IMPORT_RE = /mixed-cache(?:\.ts)?$/;
|
|
38
40
|
const ANY_MODULE_RE = /.*/;
|
|
39
41
|
const REACT_SERVER_IMPORT_RE = /^react-dom\/server(?:\.edge)?$/;
|
|
40
42
|
const REACT_STATIC_IMPORT_RE = /^react-dom\/static\.edge$/;
|
|
41
43
|
const BUILD_ID_INPUT_PATHS = [
|
|
42
44
|
`${_pkgSrcDir}/build/compile-entry${_ext}`,
|
|
43
45
|
`${_pkgSrcDir}/build/entry-template${_ext}`,
|
|
46
|
+
`${_pkgSrcDir}/build/request-keys${_ext}`,
|
|
44
47
|
`${_pkgSrcDir}/plugin/routes${_ext}`,
|
|
45
48
|
`${_pkgSrcDir}/server/render/document.tsx`,
|
|
46
49
|
`${_pkgSrcDir}/server/render/element.tsx`,
|
|
47
50
|
`${_pkgSrcDir}/server/render/index${_ext}`,
|
|
48
51
|
`${_pkgSrcDir}/server/render/isr${_ext}`,
|
|
49
52
|
`${_pkgSrcDir}/server/render/loaders${_ext}`,
|
|
53
|
+
`${_pkgSrcDir}/server/render/mixed-cache${_ext}`,
|
|
50
54
|
`${_pkgSrcDir}/server/render/not-found${_ext}`,
|
|
51
55
|
`${_pkgSrcDir}/server/render/ppr-route${_ext}`,
|
|
52
56
|
`${_pkgSrcDir}/server/render/ppr-document${_ext}`,
|
|
@@ -129,6 +133,8 @@ export async function createBuildFingerprint(
|
|
|
129
133
|
mode: route.mode,
|
|
130
134
|
path: stableFingerprintPath(route.path, projectRoot),
|
|
131
135
|
pattern: route.pattern,
|
|
136
|
+
requestKeys: route.requestKeys?.toSorted(),
|
|
137
|
+
requestKeysByLoader: route.requestKeysByLoader?.map((keys) => keys.toSorted()),
|
|
132
138
|
})
|
|
133
139
|
)
|
|
134
140
|
.sort(compareCodeUnits);
|
|
@@ -170,6 +176,8 @@ function buildCompileMetadata(root: RootLayout, routes: ResolvedRoute[]) {
|
|
|
170
176
|
const routeMetadata: NonNullable<EntryAppContext["routeMetadata"]> = {};
|
|
171
177
|
for (const route of routes) {
|
|
172
178
|
routeMetadata[toPosixPath(route.path)] = {
|
|
179
|
+
requestKeys: route.requestKeys,
|
|
180
|
+
requestKeysByLoader: route.requestKeysByLoader,
|
|
173
181
|
segmentBoundaries: route.segmentBoundaries.map((boundary) => ({
|
|
174
182
|
depth: boundary.depth,
|
|
175
183
|
errorPath: boundary.errorPath ? toPosixPath(boundary.errorPath) : undefined,
|
|
@@ -195,7 +203,7 @@ export function pprRuntimePlugin(apps: RuntimeTargetApp[]): Bun.BunPlugin {
|
|
|
195
203
|
const enabled = apps.some((app) =>
|
|
196
204
|
app.routes.some(
|
|
197
205
|
(route) =>
|
|
198
|
-
route
|
|
206
|
+
resolveDocumentMode(route) !== "ssr" &&
|
|
199
207
|
(app.root.route.requestLoader !== undefined || hasRequestLoader(route))
|
|
200
208
|
)
|
|
201
209
|
);
|
|
@@ -236,6 +244,32 @@ export const runPprPublicLoaders = renderPprRoute;`,
|
|
|
236
244
|
};
|
|
237
245
|
}
|
|
238
246
|
|
|
247
|
+
/** Keep mixed-mode cache code out of builds whose route graph cannot use it. */
|
|
248
|
+
export function mixedRuntimePlugin(apps: RuntimeTargetApp[]): Bun.BunPlugin {
|
|
249
|
+
const enabled = apps.some((app) => app.routes.some(hasMixedLoaderModes));
|
|
250
|
+
const mixedPath = resolve(_pkgSrcDir, "server/render/mixed-cache.ts");
|
|
251
|
+
return {
|
|
252
|
+
name: "furin-mixed-runtime",
|
|
253
|
+
setup(build) {
|
|
254
|
+
if (enabled) {
|
|
255
|
+
return;
|
|
256
|
+
}
|
|
257
|
+
build.onResolve({ filter: MIXED_CACHE_IMPORT_RE }, ({ path, importer }) => {
|
|
258
|
+
const absolute = resolve(dirname(importer.split("?")[0] as string), path);
|
|
259
|
+
if (absolute !== mixedPath && `${absolute}.ts` !== mixedPath) {
|
|
260
|
+
return;
|
|
261
|
+
}
|
|
262
|
+
return { namespace: "furin-no-mixed", path: "mixed" };
|
|
263
|
+
});
|
|
264
|
+
build.onLoad({ filter: ANY_MODULE_RE, namespace: "furin-no-mixed" }, () => ({
|
|
265
|
+
contents: `export function clearMixedPublicCache() {}
|
|
266
|
+
export function cacheMixedPublicLoader() { throw new Error("[furin] Mixed route missing from the build manifest."); }`,
|
|
267
|
+
loader: "js",
|
|
268
|
+
}));
|
|
269
|
+
},
|
|
270
|
+
};
|
|
271
|
+
}
|
|
272
|
+
|
|
239
273
|
function isFrameworkRuntimeImporter(importer: string): boolean {
|
|
240
274
|
if (importer === "") {
|
|
241
275
|
return false;
|
package/src/adapter/static.ts
CHANGED
|
@@ -12,6 +12,7 @@ import { generateProdIndexHtml } from "../server/render/shell.ts";
|
|
|
12
12
|
import { prerenderSSG } from "../server/render/ssg.ts";
|
|
13
13
|
import { hasStaticParams, resolveStaticParams } from "../server/render/static-params.ts";
|
|
14
14
|
import { setProductionTemplateContent } from "../server/render/template.ts";
|
|
15
|
+
import { resolveDocumentMode } from "../server/router/patterns.ts";
|
|
15
16
|
import { createSearchRouteMetadata } from "../server/router/schemas.ts";
|
|
16
17
|
import type { ResolvedRoute, RootLayout } from "../server/router/types.ts";
|
|
17
18
|
import type { SearchRouteMetadata } from "../shared/search-params.ts";
|
|
@@ -218,14 +219,19 @@ function collectSsgRoutes(
|
|
|
218
219
|
onSSR: "error" | "skip",
|
|
219
220
|
skippedRoutes: string[]
|
|
220
221
|
): ResolvedRoute[] {
|
|
221
|
-
const nonSsg = routes.filter((r) => r
|
|
222
|
+
const nonSsg = routes.filter((r) => resolveDocumentMode(r) !== "ssg");
|
|
222
223
|
|
|
223
224
|
if (nonSsg.length === 0) {
|
|
224
225
|
return routes;
|
|
225
226
|
}
|
|
226
227
|
|
|
227
228
|
if (onSSR === "error") {
|
|
228
|
-
const list = nonSsg
|
|
229
|
+
const list = nonSsg
|
|
230
|
+
.map(
|
|
231
|
+
(r) =>
|
|
232
|
+
` • ${r.pattern} (mode: ${resolveDocumentMode(r) === "ssr" && r.mode !== "ssr" ? "ssr layout" : resolveDocumentMode(r)})`
|
|
233
|
+
)
|
|
234
|
+
.join("\n");
|
|
229
235
|
throw new Error(
|
|
230
236
|
"[furin] Cannot produce a static export: the following routes are not SSG and cannot be pre-rendered.\n" +
|
|
231
237
|
`Either change their mode to "ssg", remove them, or set \`onSSR: "skip"\` in your static config.\n\n` +
|
|
@@ -236,12 +242,12 @@ function collectSsgRoutes(
|
|
|
236
242
|
// onSSR === "skip"
|
|
237
243
|
for (const r of nonSsg) {
|
|
238
244
|
console.warn(
|
|
239
|
-
`[furin] static: skipping route "${r.pattern}" (mode=${r.mode}) — not statically exportable.`
|
|
245
|
+
`[furin] static: skipping route "${r.pattern}" (mode=${resolveDocumentMode(r) === "ssr" && r.mode !== "ssr" ? "ssr layout" : resolveDocumentMode(r)}) — not statically exportable.`
|
|
240
246
|
);
|
|
241
247
|
skippedRoutes.push(r.pattern);
|
|
242
248
|
}
|
|
243
249
|
|
|
244
|
-
return routes.filter((r) => r
|
|
250
|
+
return routes.filter((r) => resolveDocumentMode(r) === "ssg");
|
|
245
251
|
}
|
|
246
252
|
|
|
247
253
|
// ── Task queue builder ────────────────────────────────────────────────────────
|