@teyik0/furin 0.3.0-alpha.1 → 0.4.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/adapter/bun.d.ts +2 -18
- package/dist/adapter/package.d.ts +2 -2
- package/dist/adapter/runtime-build.d.ts +33 -0
- package/dist/adapter/vercel.d.ts +3 -0
- package/dist/build/client.d.ts +2 -2
- package/dist/build/compile-entry.d.ts +4 -3
- package/dist/build/compile-entry.ts +24 -69
- package/dist/build/entry-template.d.ts +8 -2
- package/dist/build/entry-template.ts +48 -11
- package/dist/build/index.d.ts +2 -2
- package/dist/build/index.js +11720 -7840
- package/dist/build/route-types.d.ts +2 -22
- package/dist/build/shared.d.ts +1 -1
- package/dist/build/ssg-cache.d.ts +14 -1
- package/dist/build/types.d.ts +26 -3
- package/dist/build/virtual-entry.d.ts +8 -0
- package/dist/cache.d.ts +5 -0
- package/dist/cache.js +97 -0
- package/dist/cli/index.js +11815 -7793
- package/dist/cli/preview.d.ts +7 -0
- package/dist/client/boundaries.d.ts +3 -0
- package/dist/client/browser-events-runtime.d.ts +2 -0
- package/dist/client/browser-events.d.ts +2 -0
- package/dist/client/define-route.d.ts +36 -0
- package/dist/client/dev-error-overlay.d.ts +1 -0
- package/dist/client/dev-error-overlay.ts +201 -0
- package/dist/client/document.d.ts +27 -0
- package/dist/client/hmr.d.ts +12 -0
- package/dist/client/internal/runtime-types.d.ts +3 -1
- package/dist/client/link.js +1392 -940
- package/dist/client/router/index.d.ts +1 -1
- package/dist/client/router/link-utils.d.ts +9 -0
- package/dist/client/router/provider.d.ts +1 -1
- package/dist/client/router/search/index.d.ts +3 -7
- package/dist/client/router/sync-catch-up.d.ts +1 -1
- package/dist/client/router/types.d.ts +40 -34
- package/dist/client.d.ts +4 -159
- package/dist/client.js +197 -21
- package/dist/config.d.ts +25 -8
- package/dist/config.js +15 -7
- package/dist/define-route.d.ts +1358 -0
- package/dist/devtools/protocol.d.ts +2 -2
- package/dist/furin.d.ts +18 -34
- package/dist/furin.js +16038 -9395
- package/dist/plugin/index.js +1401 -223
- package/dist/plugin/route-config-autofix.d.ts +31 -0
- package/dist/plugin/routes.d.ts +28 -0
- package/dist/routes.d.ts +6 -0
- package/dist/routes.js +1 -0
- package/dist/rsc/build/index.d.ts +6 -2
- package/dist/rsc.js +3 -3
- package/dist/server/browser-events/plugin.d.ts +11 -0
- package/dist/server/browser-events/types.d.ts +9 -0
- package/dist/server/cache/invalidation.d.ts +1 -2
- package/dist/server/cache/isr.d.ts +1 -0
- package/dist/server/cache/purger.d.ts +7 -0
- package/dist/server/cache/runtime-cache.d.ts +21 -0
- package/dist/server/dev/browser-events.d.ts +4 -0
- package/dist/server/dev/diagnostics.d.ts +39 -0
- package/dist/server/dev/error.d.ts +17 -0
- package/dist/server/dev/graph.d.ts +86 -0
- package/dist/server/dev/plugin.d.ts +9 -0
- package/dist/server/dev/request-security.d.ts +1 -0
- package/dist/server/dev/rewrite-module-specifiers.d.ts +7 -0
- package/dist/server/dev/runtime.production.d.ts +5 -0
- package/dist/server/dev/symbolicate.d.ts +11 -0
- package/dist/server/dev/transform-failure.d.ts +4 -0
- package/dist/server/dev-page-plugin.d.ts +7 -5
- package/dist/server/dev-page-plugin.production.d.ts +1 -0
- package/dist/server/devtools/hub.d.ts +3 -2
- package/dist/server/devtools/instrumentation.d.ts +2 -2
- package/dist/server/devtools/instrumentation.production.d.ts +2 -2
- package/dist/server/devtools/plugin.d.ts +2 -2
- package/dist/server/external-prerender.d.ts +2 -0
- package/dist/server/instance.d.ts +2 -2
- package/dist/server/internal.d.ts +17 -2
- package/dist/server/internal.js +436 -1
- package/dist/server/logger.d.ts +4 -0
- package/dist/server/render/assemble.d.ts +0 -9
- package/dist/server/render/document.d.ts +4 -0
- package/dist/server/render/element.d.ts +3 -1
- package/dist/server/render/index.d.ts +2 -2
- package/dist/server/render/index.ts +1 -2
- package/dist/server/render/isr.d.ts +1 -1
- package/dist/server/render/loaders.d.ts +1 -1
- package/dist/server/render/not-found.d.ts +1 -1
- package/dist/server/render/ppr-document.d.ts +21 -0
- package/dist/server/render/ppr-request.d.ts +26 -0
- package/dist/server/render/ppr-route.d.ts +4 -2
- package/dist/server/render/shell.ts +0 -12
- package/dist/server/render/ssg.d.ts +3 -1
- package/dist/server/render/ssr.d.ts +23 -11
- package/dist/server/render/template.d.ts +4 -0
- package/dist/server/router/defined-route.d.ts +24 -0
- package/dist/server/router/hmr.d.ts +16 -8
- package/dist/server/router/hmr.production.d.ts +2 -0
- package/dist/server/router/patterns.d.ts +7 -0
- package/dist/server/router/plugin.d.ts +6 -3
- package/dist/server/router/schema-merge.d.ts +2 -2
- package/dist/server/router/schemas.d.ts +5 -5
- package/dist/server/router/source-version.d.ts +2 -0
- package/dist/server/router/types.d.ts +1 -0
- package/dist/server/sync/adapter.d.ts +13 -0
- package/dist/server/sync/config.d.ts +5 -5
- package/dist/server/sync/index.d.ts +6 -6
- package/dist/server/sync/index.js +1115 -985
- package/dist/server/sync/notifier.d.ts +1 -0
- package/dist/server/sync/postgres/index.d.ts +12 -1
- package/dist/server/sync/postgres/index.js +101 -6
- package/dist/server/sync/postgres/migrate.js +3 -2
- package/dist/server/sync/stream.d.ts +4 -13
- package/dist/shared/await.d.ts +4 -5
- package/dist/shared/browser-events.d.ts +22 -0
- package/dist/shared/compact-json.d.ts +8 -0
- package/dist/shared/deferred-ndjson.d.ts +6 -5
- package/dist/shared/dev-diagnostics.d.ts +36 -0
- package/dist/shared/elysia-contract.d.ts +41 -0
- package/dist/shared/prefix.d.ts +2 -0
- package/dist/shared/route-map.d.ts +5 -0
- package/dist/shared/utils/index.d.ts +1 -3
- package/package.json +55 -43
- package/src/adapter/README.md +45 -0
- package/src/adapter/bun.ts +62 -265
- package/src/adapter/package.ts +34 -22
- package/src/adapter/runtime-build.ts +375 -0
- package/src/adapter/static.ts +83 -5
- package/src/adapter/vercel.ts +857 -0
- package/src/build/client.ts +58 -16
- package/src/build/compile-entry.ts +24 -69
- package/src/build/entry-template.ts +48 -11
- package/src/build/hydrate.ts +147 -37
- package/src/build/index.ts +21 -7
- package/src/build/production-instrumentation.ts +56 -4
- package/src/build/route-types.ts +19 -114
- package/src/build/shared.ts +3 -2
- package/src/build/ssg-cache.ts +99 -16
- package/src/build/types.ts +32 -3
- package/src/build/virtual-entry.ts +27 -0
- package/src/cache.ts +14 -0
- package/src/cli/config.ts +3 -3
- package/src/cli/index.ts +62 -10
- package/src/cli/preview.ts +90 -0
- package/src/client/boundaries.tsx +19 -2
- package/src/client/browser-events-runtime.ts +204 -0
- package/src/client/browser-events.ts +22 -0
- package/src/client/define-route.ts +38 -0
- package/src/client/dev-error-overlay.ts +201 -0
- package/src/client/document.tsx +162 -0
- package/src/client/hmr.ts +63 -0
- package/src/client/internal/runtime-types.ts +3 -1
- package/src/client/link.tsx +21 -6
- package/src/client/router/boundary-tree.tsx +4 -4
- package/src/client/router/index.ts +1 -0
- package/src/client/router/link-utils.ts +26 -0
- package/src/client/router/provider.tsx +190 -65
- package/src/client/router/search/index.ts +4 -12
- package/src/client/router/sync-catch-up.ts +3 -4
- package/src/client/router/types.ts +56 -30
- package/src/client.ts +14 -316
- package/src/config.ts +35 -10
- package/src/define-route.ts +972 -0
- package/src/devtools/devtools-element.js +67 -87
- package/src/devtools/protocol.ts +2 -2
- package/src/furin.ts +431 -101
- package/src/plugin/route-config-autofix.ts +1140 -0
- package/src/plugin/routes.ts +1061 -0
- package/src/plugin/transform-client.ts +776 -228
- package/src/plugin/transform-isomorphic.ts +1 -1
- package/src/react-dom-edge.d.ts +6 -0
- package/src/routes.ts +6 -0
- package/src/rsc/build/index.ts +16 -4
- package/src/server/auto-invalidate/registry.ts +2 -2
- package/src/server/auto-invalidate/runtime.ts +5 -2
- package/src/server/browser-events/plugin.ts +168 -0
- package/src/server/browser-events/types.ts +11 -0
- package/src/server/cache/dev-loader.ts +30 -29
- package/src/server/cache/invalidation.ts +13 -22
- package/src/server/cache/isr.ts +9 -0
- package/src/server/cache/purger.ts +41 -0
- package/src/server/cache/runtime-cache.ts +137 -0
- package/src/server/dev/browser-events.ts +54 -0
- package/src/server/dev/diagnostics.ts +297 -0
- package/src/server/dev/error.ts +148 -0
- package/src/server/dev/graph.ts +438 -0
- package/src/server/dev/plugin.ts +130 -0
- package/src/server/dev/request-security.ts +38 -0
- package/src/server/dev/rewrite-module-specifiers.ts +81 -0
- package/src/server/dev/runtime.production.ts +24 -0
- package/src/server/dev/symbolicate.ts +135 -0
- package/src/server/dev/transform-failure.ts +8 -0
- package/src/server/dev-page-plugin.production.ts +3 -0
- package/src/server/dev-page-plugin.ts +110 -52
- package/src/server/devtools/hub.ts +6 -5
- package/src/server/devtools/instrumentation.production.ts +3 -3
- package/src/server/devtools/instrumentation.ts +14 -8
- package/src/server/devtools/plugin.ts +12 -153
- package/src/server/external-prerender.ts +10 -0
- package/src/server/instance.ts +5 -5
- package/src/server/internal.ts +42 -2
- package/src/server/logger.ts +21 -0
- package/src/server/render/assemble.ts +4 -45
- package/src/server/render/document.tsx +34 -0
- package/src/server/render/element.tsx +31 -15
- package/src/server/render/index.ts +1 -2
- package/src/server/render/isr.ts +70 -24
- package/src/server/render/loaders.ts +43 -8
- package/src/server/render/not-found.ts +77 -29
- package/src/server/render/ppr-document.ts +239 -0
- package/src/server/render/ppr-request.ts +104 -0
- package/src/server/render/ppr-route.ts +153 -32
- package/src/server/render/shell.ts +0 -12
- package/src/server/render/ssg.ts +39 -21
- package/src/server/render/ssr.ts +429 -143
- package/src/server/render/template.ts +128 -2
- package/src/server/router/defined-route.ts +78 -0
- package/src/server/router/discovery.ts +129 -29
- package/src/server/router/hmr.production.ts +7 -0
- package/src/server/router/hmr.ts +177 -67
- package/src/server/router/patterns.ts +45 -13
- package/src/server/router/plugin.ts +184 -78
- package/src/server/router/schema-merge.ts +4 -14
- package/src/server/router/schemas.ts +11 -8
- package/src/server/router/source-version.ts +9 -0
- package/src/server/router/types.ts +2 -0
- package/src/server/sync/adapter.ts +13 -0
- package/src/server/sync/config.ts +12 -12
- package/src/server/sync/index.ts +8 -8
- package/src/server/sync/notifier.ts +1 -0
- package/src/server/sync/plugin.ts +4 -1
- package/src/server/sync/postgres/index.ts +111 -5
- package/src/server/sync/postgres/migrate.ts +3 -2
- package/src/server/sync/response.ts +14 -10
- package/src/server/sync/runtime.ts +12 -0
- package/src/server/sync/stream.ts +78 -113
- package/src/shared/await.tsx +4 -5
- package/src/shared/browser-events.ts +28 -0
- package/src/shared/compact-json.ts +77 -0
- package/src/shared/deferred-ndjson.ts +20 -6
- package/src/shared/dev-diagnostics.ts +44 -0
- package/src/shared/elysia-contract.ts +63 -0
- package/src/shared/prefix.ts +8 -0
- package/src/shared/route-map.ts +46 -0
- package/src/shared/utils/index.ts +2 -20
- package/dist/build/server-routes-entry.d.ts +0 -13
- package/dist/build/server-routes-entry.ts +0 -30
- package/dist/server/router/index.d.ts +0 -7
- package/dist/server/router/index.js +0 -27
- package/dist/server/router/index.ts +0 -28
- package/src/build/server-routes-entry.ts +0 -30
- package/src/server/router/index.ts +0 -28
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
export interface ExpectedLayout {
|
|
2
|
+
/** Preferred local binding, e.g. "rootRoute". */
|
|
3
|
+
identifier: string;
|
|
4
|
+
/** Import specifier relative from the route file, e.g. "../root". */
|
|
5
|
+
importPath: string;
|
|
6
|
+
}
|
|
7
|
+
export type LayoutProbe = (path: string) => boolean;
|
|
8
|
+
/** Deterministic binding for a layout file: `root.tsx` → `rootRoute`, `board/_route.tsx` → `boardRoute`. */
|
|
9
|
+
export declare function layoutIdentifierFor(layoutPath: string): string;
|
|
10
|
+
/**
|
|
11
|
+
* The layout a route file should reference: the nearest `_route.ts(x)` walking
|
|
12
|
+
* up from its own directory (a `_route` file looks at its PARENT directory),
|
|
13
|
+
* falling back to the `root.tsx` convention at the pages root. Returns null
|
|
14
|
+
* for the root layout itself — nothing above it exists.
|
|
15
|
+
*/
|
|
16
|
+
export declare function expectedLayoutFor(filePath: string, pagesDir: string, probe?: LayoutProbe): ExpectedLayout | null;
|
|
17
|
+
/** Dynamic param names derived from the file path segments (`[id]` → id, `[...all]` → "*"). */
|
|
18
|
+
export declare function dynamicParamsFor(filePath: string, pagesDir: string): string[];
|
|
19
|
+
/**
|
|
20
|
+
* Rewrites `defineRoute()` chains so every route file declares a full
|
|
21
|
+
* `config({ layout, mode, ... })`:
|
|
22
|
+
* - chain without `config()` → inserts `.config({ layout, mode })`
|
|
23
|
+
* - `config()` without `layout` → injects the expected ancestor layout
|
|
24
|
+
* - `config()` with a WRONG layout → repoints the reference (and its import)
|
|
25
|
+
* - `config()` without `mode` → infers the mode using the runtime cascade
|
|
26
|
+
* - layout file without `layout()` → appends an identity layout terminal
|
|
27
|
+
* The root layout (`pages/root.tsx`, built with `defineRootRoute()`) never
|
|
28
|
+
* receives a parent `layout` config entry. Returns the new source, or null when unchanged
|
|
29
|
+
* (idempotent — running the fix twice returns null on the second pass).
|
|
30
|
+
*/
|
|
31
|
+
export declare function fixRouteConfigLayout(source: string, filePath: string, pagesDir: string, probe?: LayoutProbe): string | null;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
export interface RouteInstanceSpec {
|
|
2
|
+
pagesDir: string;
|
|
3
|
+
prefix: string;
|
|
4
|
+
}
|
|
5
|
+
export interface CreateRoutesPluginOptions {
|
|
6
|
+
instances: RouteInstanceSpec[];
|
|
7
|
+
target: "client" | "server";
|
|
8
|
+
}
|
|
9
|
+
export interface DevRouteTopologyWatcher {
|
|
10
|
+
close: () => void;
|
|
11
|
+
refresh: () => Promise<void>;
|
|
12
|
+
}
|
|
13
|
+
export interface DevRouteTopologyWatcherOptions {
|
|
14
|
+
instance: RouteInstanceSpec;
|
|
15
|
+
onRouteFilesTouched?: (sourcePaths: readonly string[]) => Promise<void> | void;
|
|
16
|
+
onSourceError?: (error: unknown, sourcePath: string) => void;
|
|
17
|
+
onTopologyChange: (sourcePaths: readonly string[]) => Promise<void> | void;
|
|
18
|
+
}
|
|
19
|
+
export declare function routeModuleSpecifier(instance: RouteInstanceSpec): string;
|
|
20
|
+
export declare function routeSourcePaths(instance: RouteInstanceSpec): string[];
|
|
21
|
+
export declare function registerDevRouteTopologyWatcher(options: DevRouteTopologyWatcherOptions): DevRouteTopologyWatcher;
|
|
22
|
+
export declare function validateRouteParams(path: string, schemas: {
|
|
23
|
+
params?: {
|
|
24
|
+
properties?: object;
|
|
25
|
+
};
|
|
26
|
+
} | undefined): void;
|
|
27
|
+
export declare function registerDevRoutesPlugin(instances: RouteInstanceSpec[]): void;
|
|
28
|
+
export declare function createRoutesPlugin(options: CreateRoutesPluginOptions): Bun.BunPlugin;
|
package/dist/routes.d.ts
ADDED
package/dist/routes.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
// @bun
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ResolvedRoute, RootLayout } from "../../server/router/
|
|
1
|
+
import type { ResolvedRoute, RootLayout } from "../../server/router/types.ts";
|
|
2
2
|
export interface ClientReference {
|
|
3
3
|
chunks: readonly string[];
|
|
4
4
|
id: string;
|
|
@@ -12,4 +12,8 @@ export interface RscManifest {
|
|
|
12
12
|
clientReferences: readonly ClientReference[];
|
|
13
13
|
css: readonly RscCssAsset[];
|
|
14
14
|
}
|
|
15
|
-
export
|
|
15
|
+
export interface RscBuildApp {
|
|
16
|
+
root: RootLayout;
|
|
17
|
+
routes: ResolvedRoute[];
|
|
18
|
+
}
|
|
19
|
+
export declare function buildRscGraph(apps: RscBuildApp[], outDir: string, buildId: string, userPlugins: Bun.BunPlugin[] | undefined): Promise<RscManifest>;
|
package/dist/rsc.js
CHANGED
|
@@ -135,9 +135,9 @@ async function drainFlight(session, operation) {
|
|
|
135
135
|
try {
|
|
136
136
|
bytes = await readFlightBytes(session.stream);
|
|
137
137
|
} catch (streamError) {
|
|
138
|
-
const
|
|
139
|
-
if (
|
|
140
|
-
throw createFurinRscRenderError(
|
|
138
|
+
const renderError = session.getRenderError();
|
|
139
|
+
if (renderError.reported) {
|
|
140
|
+
throw createFurinRscRenderError(renderError.error, operation);
|
|
141
141
|
}
|
|
142
142
|
throw streamError;
|
|
143
143
|
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { type AnyElysia } from "elysia";
|
|
2
|
+
import type { FurinSyncOptions } from "../sync/config.ts";
|
|
3
|
+
import type { BrowserEventSource } from "./types.ts";
|
|
4
|
+
interface BrowserEventsPluginOptions {
|
|
5
|
+
sources?: readonly BrowserEventSource[];
|
|
6
|
+
sync?: FurinSyncOptions;
|
|
7
|
+
}
|
|
8
|
+
export declare function createBrowserEventsPlugin(options: BrowserEventsPluginOptions): AnyElysia;
|
|
9
|
+
export declare function browserEventsClientScript(basePath: string): string;
|
|
10
|
+
export declare function injectBrowserEventsClient(html: string, basePath: string): string;
|
|
11
|
+
export {};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { BrowserEventEnvelope } from "../../shared/browser-events.ts";
|
|
2
|
+
export interface BrowserEventSubscription {
|
|
3
|
+
unsubscribe: () => void;
|
|
4
|
+
}
|
|
5
|
+
export interface BrowserEventSource {
|
|
6
|
+
subscribe: (listener: (event: Exclude<BrowserEventEnvelope, {
|
|
7
|
+
channel: "sync";
|
|
8
|
+
}>) => void) => Promise<BrowserEventSubscription> | BrowserEventSubscription;
|
|
9
|
+
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { type FurinInstance } from "../instance.ts";
|
|
2
|
+
import { type CachePurger } from "./purger.ts";
|
|
2
3
|
import type { RevalidateType } from "./route-cache";
|
|
3
4
|
export declare function _runWithRequestInvalidationScope<T>(fn: () => T): T;
|
|
4
5
|
export declare function consumePendingInvalidations(): string[];
|
|
5
6
|
export declare function peekPendingInvalidations(): string[];
|
|
6
|
-
type CachePurger = (paths: string[]) => Promise<void>;
|
|
7
7
|
export declare function setCachePurger(fn: CachePurger): void;
|
|
8
8
|
export declare function callCachePurger(paths: string[]): void;
|
|
9
9
|
/**
|
|
@@ -27,4 +27,3 @@ export declare function revalidatePathForInstance(instance: FurinInstance, path:
|
|
|
27
27
|
};
|
|
28
28
|
/** @internal — resets all module state between tests */
|
|
29
29
|
export declare function __resetCacheState(): void;
|
|
30
|
-
export {};
|
|
@@ -16,4 +16,5 @@ export declare function releaseISRCacheGeneration(key: string, generation: ISRCa
|
|
|
16
16
|
export declare function setISRCacheIfGenerationUnchanged(key: string, entry: ISRCacheEntry, generation: ISRCacheGeneration): boolean;
|
|
17
17
|
export declare function pendingISRRevalidations(): Map<string, Promise<void>>;
|
|
18
18
|
export declare function clearPendingISRRevalidations(instance?: FurinInstance): void;
|
|
19
|
+
export declare function hasPendingISRRevalidations(): boolean;
|
|
19
20
|
export declare function waitForPendingISRRevalidations(): Promise<void>;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export type CachePurger = (keys: string[]) => Promise<void>;
|
|
2
|
+
export declare function setCachePurger(purger: CachePurger): void;
|
|
3
|
+
/** Deployment-only semantic tag hook; the public CDN hook remains path-only. */
|
|
4
|
+
export declare function setCacheTagPurger(purger: CachePurger): void;
|
|
5
|
+
export declare function callCachePurger(paths: string[]): void;
|
|
6
|
+
export declare function callCacheTagPurger(tags: string[]): void;
|
|
7
|
+
export declare function resetCachePurgers(): void;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export interface RuntimeCacheOptions {
|
|
2
|
+
namespace?: string;
|
|
3
|
+
}
|
|
4
|
+
export interface RuntimeCacheSetOptions {
|
|
5
|
+
name?: string;
|
|
6
|
+
tags?: string[];
|
|
7
|
+
ttl?: number;
|
|
8
|
+
}
|
|
9
|
+
export interface RuntimeCache {
|
|
10
|
+
delete: (key: string) => Promise<void>;
|
|
11
|
+
expireTag: (tag: string | string[]) => Promise<void>;
|
|
12
|
+
get: (key: string) => Promise<unknown | null>;
|
|
13
|
+
set: (key: string, value: unknown, options?: RuntimeCacheSetOptions) => Promise<void>;
|
|
14
|
+
}
|
|
15
|
+
export interface RuntimeCacheProvider {
|
|
16
|
+
getCache: (options: RuntimeCacheOptions | undefined) => RuntimeCache;
|
|
17
|
+
}
|
|
18
|
+
export declare function getCache(options?: RuntimeCacheOptions): RuntimeCache;
|
|
19
|
+
export declare function setRuntimeCacheProvider(provider: RuntimeCacheProvider): void;
|
|
20
|
+
export declare function hasExternalRuntimeCache(): boolean;
|
|
21
|
+
export declare function resetRuntimeCacheProvider(): void;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { BrowserEventSource } from "../browser-events/types.ts";
|
|
2
|
+
import type { FurinInstance } from "../instance.ts";
|
|
3
|
+
import type { DevDiagnosticStore } from "./diagnostics.ts";
|
|
4
|
+
export declare function createDevelopmentBrowserEventSources(instance: FurinInstance, diagnostics: DevDiagnosticStore): readonly BrowserEventSource[];
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { type DevDiagnostic, type DevDiagnosticEvent, type DevDiagnosticPhase } from "../../shared/dev-diagnostics.ts";
|
|
2
|
+
import { type FurinInstance } from "../instance.ts";
|
|
3
|
+
interface DiagnosticContext {
|
|
4
|
+
entryPath: string;
|
|
5
|
+
importChain: readonly string[] | undefined;
|
|
6
|
+
phase: DevDiagnosticPhase;
|
|
7
|
+
route: string;
|
|
8
|
+
}
|
|
9
|
+
export interface ClientErrorReport {
|
|
10
|
+
cause: string | undefined;
|
|
11
|
+
message: string;
|
|
12
|
+
phase: "client-render" | "hydrate";
|
|
13
|
+
route: string;
|
|
14
|
+
stack: string | undefined;
|
|
15
|
+
}
|
|
16
|
+
export declare function createDevDiagnostic(error: unknown, context: DiagnosticContext): DevDiagnostic;
|
|
17
|
+
export declare class DevDiagnosticStore {
|
|
18
|
+
#private;
|
|
19
|
+
constructor();
|
|
20
|
+
get revision(): number;
|
|
21
|
+
markReady(route: string): DevDiagnosticEvent | undefined;
|
|
22
|
+
publish(diagnostic: DevDiagnostic): Extract<DevDiagnosticEvent, {
|
|
23
|
+
type: "error";
|
|
24
|
+
}>;
|
|
25
|
+
subscribe(after: number, serverId: string | undefined, listener: (event: DevDiagnosticEvent) => void): {
|
|
26
|
+
replay: readonly DevDiagnosticEvent[];
|
|
27
|
+
unsubscribe: () => void;
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
export declare function devDiagnosticStore(instance?: FurinInstance): DevDiagnosticStore;
|
|
31
|
+
export declare function publishDevDiagnostic(error: unknown, context: Omit<DiagnosticContext, "importChain"> & {
|
|
32
|
+
importChain?: readonly string[];
|
|
33
|
+
}): Extract<DevDiagnosticEvent, {
|
|
34
|
+
type: "error";
|
|
35
|
+
}>;
|
|
36
|
+
export declare function publishClientDiagnostic(store: DevDiagnosticStore, report: ClientErrorReport, origin: string, instance: FurinInstance | undefined): Promise<Extract<DevDiagnosticEvent, {
|
|
37
|
+
type: "error";
|
|
38
|
+
}>>;
|
|
39
|
+
export {};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { DevErrorPayload, DevErrorPhase, DevGraph, DevGraphEvent } from "./graph.ts";
|
|
2
|
+
interface DevErrorContext {
|
|
3
|
+
entryPath: string;
|
|
4
|
+
importChain: string[];
|
|
5
|
+
phase: DevErrorPhase;
|
|
6
|
+
route: string;
|
|
7
|
+
}
|
|
8
|
+
interface PublishDevErrorContext {
|
|
9
|
+
entryPath: string;
|
|
10
|
+
phase: DevErrorPhase;
|
|
11
|
+
route: string;
|
|
12
|
+
}
|
|
13
|
+
export declare function createDevErrorPayload(error: unknown, context: DevErrorContext): DevErrorPayload;
|
|
14
|
+
export declare function publishDevError<Snapshot>(graph: DevGraph<Snapshot>, error: unknown, context: PublishDevErrorContext): Extract<DevGraphEvent, {
|
|
15
|
+
type: "error";
|
|
16
|
+
}>;
|
|
17
|
+
export {};
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import type { FurinRouteDispatcher } from "../../define-route.ts";
|
|
2
|
+
import { type FurinInstance } from "../instance.ts";
|
|
3
|
+
import type { ResolvedRoute, RootLayout } from "../router/types.ts";
|
|
4
|
+
export declare const DEV_ERROR_PROTOCOL_VERSION = 1;
|
|
5
|
+
export type DevErrorPhase = "hydrate" | "import" | "loader" | "render" | "transform";
|
|
6
|
+
export interface DevErrorPayload {
|
|
7
|
+
cause: string | null;
|
|
8
|
+
column: number | null;
|
|
9
|
+
file: string | null;
|
|
10
|
+
importChain: string[];
|
|
11
|
+
line: number | null;
|
|
12
|
+
message: string;
|
|
13
|
+
phase: DevErrorPhase;
|
|
14
|
+
route: string;
|
|
15
|
+
stack: string | null;
|
|
16
|
+
}
|
|
17
|
+
export interface DevelopmentRouteSnapshot {
|
|
18
|
+
render: FurinRouteDispatcher;
|
|
19
|
+
root: RootLayout;
|
|
20
|
+
routes: ResolvedRoute[];
|
|
21
|
+
}
|
|
22
|
+
interface DevEventBase {
|
|
23
|
+
id: number;
|
|
24
|
+
revision: number;
|
|
25
|
+
serverId: string;
|
|
26
|
+
version: typeof DEV_ERROR_PROTOCOL_VERSION;
|
|
27
|
+
}
|
|
28
|
+
export type DevGraphEvent = (DevEventBase & {
|
|
29
|
+
error: DevErrorPayload;
|
|
30
|
+
type: "error";
|
|
31
|
+
}) | (DevEventBase & {
|
|
32
|
+
type: "ready";
|
|
33
|
+
});
|
|
34
|
+
export interface DevGraphMetrics {
|
|
35
|
+
events: number;
|
|
36
|
+
modules: number;
|
|
37
|
+
revision: number;
|
|
38
|
+
}
|
|
39
|
+
export interface DevSourcePosition {
|
|
40
|
+
column: number | null;
|
|
41
|
+
file: string;
|
|
42
|
+
line: number | null;
|
|
43
|
+
}
|
|
44
|
+
type DevModuleImporter<Module> = (specifier: string) => Promise<Module>;
|
|
45
|
+
export declare function resolveDevSourceImports(source: string, path: string, loader: "js" | "jsx" | "ts" | "tsx"): {
|
|
46
|
+
imports: string[];
|
|
47
|
+
transpiler: Bun.Transpiler;
|
|
48
|
+
};
|
|
49
|
+
/**
|
|
50
|
+
* Single source of truth for development runtime state.
|
|
51
|
+
*
|
|
52
|
+
* A graph commit swaps the complete route snapshot before publishing `ready`,
|
|
53
|
+
* so requests never observe a partially rebuilt route tree. Module identities,
|
|
54
|
+
* per-runtime cache state, compilation revisions, and overlay events share the
|
|
55
|
+
* same lifetime.
|
|
56
|
+
*/
|
|
57
|
+
export declare class DevGraph<Snapshot> {
|
|
58
|
+
#private;
|
|
59
|
+
constructor(initialSnapshot: Snapshot);
|
|
60
|
+
get events(): DevGraphEvent[];
|
|
61
|
+
get revision(): number;
|
|
62
|
+
get metrics(): DevGraphMetrics;
|
|
63
|
+
get snapshot(): Snapshot;
|
|
64
|
+
commit(snapshot: Snapshot): void;
|
|
65
|
+
diagnoseTransformError(entryPath: string, message: string): DevSourcePosition | undefined;
|
|
66
|
+
importModule<Module>(path: string, sourceVersion: string, importModule: DevModuleImporter<Module>): Promise<Module>;
|
|
67
|
+
importChain(from: string, to: string): string[];
|
|
68
|
+
dependsOn(from: string, to: string): boolean;
|
|
69
|
+
clearSourceErrors(path: string): void;
|
|
70
|
+
publishError(error: DevErrorPayload): Extract<DevGraphEvent, {
|
|
71
|
+
type: "error";
|
|
72
|
+
}>;
|
|
73
|
+
recordImports(importer: string, imports: string[]): void;
|
|
74
|
+
recordSourceError(message: string, position: DevSourcePosition): void;
|
|
75
|
+
sourceError(message: string, entryPath: string): DevSourcePosition | undefined;
|
|
76
|
+
invalidateModules(): void;
|
|
77
|
+
sourceVersion(path: string): string;
|
|
78
|
+
state<Value>(key: symbol, initialize: () => Value): Value;
|
|
79
|
+
subscribe(after: number, serverId: string | undefined, listener: (event: DevGraphEvent) => void): {
|
|
80
|
+
replay: DevGraphEvent[];
|
|
81
|
+
unsubscribe: () => void;
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
export declare function developmentGraphs(): DevGraph<DevelopmentRouteSnapshot | null>[];
|
|
85
|
+
export declare function devGraph(instance: FurinInstance | undefined): DevGraph<DevelopmentRouteSnapshot | null>;
|
|
86
|
+
export {};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { type AnyElysia } from "elysia";
|
|
2
|
+
import type { DevDiagnosticEvent } from "../../shared/dev-diagnostics.ts";
|
|
3
|
+
import type { FurinInstance } from "../instance.ts";
|
|
4
|
+
import { type DevDiagnosticStore } from "./diagnostics.ts";
|
|
5
|
+
export declare function createDevDiagnosticPlugin(store: DevDiagnosticStore, instance: FurinInstance | undefined, reconcileRoutes: (() => Promise<void>) | undefined): AnyElysia;
|
|
6
|
+
export declare function injectDevDiagnosticClient(html: string, basePath: string): string;
|
|
7
|
+
export declare function renderDevDiagnosticResponse(event: Extract<DevDiagnosticEvent, {
|
|
8
|
+
type: "error";
|
|
9
|
+
}>, basePath: string): Response;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function forbiddenDevelopmentRequest(request: Request, server: Bun.Server<unknown> | null): Response | undefined;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { type AnyElysia } from "elysia";
|
|
2
|
+
export declare function createDevDiagnosticPlugin(_store: undefined, _instance: unknown, _reconcileRoutes: unknown): AnyElysia;
|
|
3
|
+
export declare function createDevelopmentBrowserEventSources(_instance: unknown, _diagnostics: undefined): readonly never[];
|
|
4
|
+
export declare function devDiagnosticStore(): undefined;
|
|
5
|
+
export declare function injectDevDiagnosticClient(html: string, _basePath: string): string;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { DevSourceLocation, DevStackFrame } from "../../shared/dev-diagnostics.ts";
|
|
2
|
+
interface SymbolicateStackInput {
|
|
3
|
+
origin: string;
|
|
4
|
+
stack: string | undefined;
|
|
5
|
+
}
|
|
6
|
+
interface SymbolicatedStack {
|
|
7
|
+
frames: readonly DevStackFrame[];
|
|
8
|
+
location: DevSourceLocation | undefined;
|
|
9
|
+
}
|
|
10
|
+
export declare function symbolicateStack(input: SymbolicateStackInput): Promise<SymbolicatedStack>;
|
|
11
|
+
export {};
|
|
@@ -16,16 +16,18 @@
|
|
|
16
16
|
* stale module while the client received fresh HMR code, causing a React
|
|
17
17
|
* hydration mismatch.
|
|
18
18
|
*
|
|
19
|
-
* Solution: the caller appends `?furin-server&t=<
|
|
20
|
-
* specifier
|
|
21
|
-
*
|
|
22
|
-
*
|
|
19
|
+
* Solution: the caller appends `?furin-server&t=<source-version>` to the import
|
|
20
|
+
* specifier. `onResolve` preserves the `?t=...` fragment in the resolved path,
|
|
21
|
+
* so Bun calls `onLoad` again after an edit without allocating a new permanent
|
|
22
|
+
* ESM registry entry for every request.
|
|
23
23
|
*
|
|
24
24
|
* ## Relative import rewriting
|
|
25
25
|
*
|
|
26
26
|
* Modules in a virtual namespace cannot resolve relative specifiers on their
|
|
27
27
|
* own (there is no real directory context). We rewrite every `./` / `../`
|
|
28
|
-
* path to an absolute one before returning the source.
|
|
28
|
+
* path to an absolute one before returning the source. Local JS/TS dependencies
|
|
29
|
+
* use the same source-version rule as routes, so refreshing a route does not
|
|
30
|
+
* retain an old helper module. Shared dependencies keep one identity per version.
|
|
29
31
|
*
|
|
30
32
|
* ## Bare specifier rewriting
|
|
31
33
|
*
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function registerDevPagePlugin(): void;
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { type DevtoolsServerEvent, type DevtoolsServerEventInput } from "../../devtools/protocol.ts";
|
|
2
|
+
import { type FurinInstance } from "../instance.ts";
|
|
2
3
|
export declare function devtoolsInstanceId(): string;
|
|
3
|
-
export declare function devtoolsEventsSnapshot(): {
|
|
4
|
+
export declare function devtoolsEventsSnapshot(instance?: FurinInstance): {
|
|
4
5
|
events: DevtoolsServerEvent[];
|
|
5
6
|
lastEventId: number;
|
|
6
7
|
};
|
|
7
|
-
export declare function subscribeDevtoolsEventsAfter(cursor: number, listener: (event: DevtoolsServerEvent) => void): {
|
|
8
|
+
export declare function subscribeDevtoolsEventsAfter(cursor: number, listener: (event: DevtoolsServerEvent) => void, instance?: FurinInstance): {
|
|
8
9
|
replay: DevtoolsServerEvent[];
|
|
9
10
|
unsubscribe: () => void;
|
|
10
11
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { AnyElysia } from "elysia";
|
|
2
2
|
import type { DevtoolsServerEventInput } from "../../devtools/protocol.ts";
|
|
3
|
-
import type {
|
|
3
|
+
import type { ResolvedRoutesSource } from "../router/types.ts";
|
|
4
4
|
import { type DevtoolsRequestContext } from "./request-context.ts";
|
|
5
5
|
type EventInput<T extends DevtoolsServerEventInput["type"]> = Omit<Extract<DevtoolsServerEventInput, {
|
|
6
6
|
type: T;
|
|
@@ -17,6 +17,6 @@ export declare function currentInstrumentationRequest(): DevtoolsRequestContext
|
|
|
17
17
|
export declare function runWithRequestInstrumentation<T>(request: Request, fn: () => T): T;
|
|
18
18
|
export declare function shouldInstrumentRequest(pathname: string, prefix: string): boolean;
|
|
19
19
|
export declare function instrumentationLoggerExclusions(prefix: string): string[];
|
|
20
|
-
export declare function createInstrumentationPlugin(routes:
|
|
20
|
+
export declare function createInstrumentationPlugin(routes: ResolvedRoutesSource, syncPath: string | undefined): AnyElysia;
|
|
21
21
|
export declare function injectInstrumentationClient(html: string, prefix: string): string;
|
|
22
22
|
export {};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type AnyElysia } from "elysia";
|
|
2
|
-
import type {
|
|
2
|
+
import type { ResolvedRoutesSource } from "../router/types.ts";
|
|
3
3
|
interface CacheAccessInput {
|
|
4
4
|
cache: "isr-loader" | "ssg-loader";
|
|
5
5
|
operationId: string | null;
|
|
@@ -39,6 +39,6 @@ export declare function currentInstrumentationRequest(): void;
|
|
|
39
39
|
export declare function runWithRequestInstrumentation<T>(_request: Request, fn: () => T): T;
|
|
40
40
|
export declare function shouldInstrumentRequest(_pathname: string, _prefix: string): boolean;
|
|
41
41
|
export declare function instrumentationLoggerExclusions(_prefix: string): string[];
|
|
42
|
-
export declare function createInstrumentationPlugin(_routes:
|
|
42
|
+
export declare function createInstrumentationPlugin(_routes: ResolvedRoutesSource, _syncPath: string | undefined): AnyElysia;
|
|
43
43
|
export declare function injectInstrumentationClient(html: string, _prefix: string): string;
|
|
44
44
|
export {};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { type AnyElysia } from "elysia";
|
|
2
|
-
import type {
|
|
3
|
-
export declare function createDevtoolsPlugin(
|
|
2
|
+
import type { ResolvedRoutesSource } from "../router/types.ts";
|
|
3
|
+
export declare function createDevtoolsPlugin(routesSource: ResolvedRoutesSource, syncPath: string | undefined): AnyElysia;
|
|
@@ -8,8 +8,8 @@ export interface FurinInstance {
|
|
|
8
8
|
registrationEpoch: number;
|
|
9
9
|
/** Generic per-instance state bag backing `instanceSlot()`. */
|
|
10
10
|
readonly state: Map<symbol, unknown>;
|
|
11
|
-
/** Logical sync
|
|
12
|
-
|
|
11
|
+
/** Logical durable sync path (unprefixed) injected into HTML, or undefined. */
|
|
12
|
+
syncPath: string | undefined;
|
|
13
13
|
}
|
|
14
14
|
export declare function createInstance(prefix: string, pagesDir: string): FurinInstance;
|
|
15
15
|
/** @internal Called by the request wrap for every served request. */
|
|
@@ -1,7 +1,10 @@
|
|
|
1
|
+
import type { AnyElysia } from "elysia";
|
|
1
2
|
import type { SsgCacheEntry } from "./cache/index.ts";
|
|
3
|
+
import { type RuntimeCacheProvider } from "./cache/runtime-cache.ts";
|
|
4
|
+
import { restorePprResumeRequest as restoreResumeRequest } from "./render/ppr-request.ts";
|
|
2
5
|
export interface EmbeddedAppData {
|
|
3
|
-
|
|
4
|
-
|
|
6
|
+
clientDir: string;
|
|
7
|
+
publicDir?: string;
|
|
5
8
|
}
|
|
6
9
|
export interface CompileContextRoute {
|
|
7
10
|
mode: "ssr" | "ssg" | "isr";
|
|
@@ -14,6 +17,8 @@ export interface CompileContext {
|
|
|
14
17
|
clientLogging?: boolean;
|
|
15
18
|
embedded?: EmbeddedAppData;
|
|
16
19
|
modules: Record<string, unknown>;
|
|
20
|
+
/** Elysia-native route tree generated for this mounted app. */
|
|
21
|
+
nativeRoutes?: AnyElysia;
|
|
17
22
|
/** Mount prefix this app was built for (`""` = root). */
|
|
18
23
|
prefix?: string;
|
|
19
24
|
/** Root-level conventions discovered at compile time. */
|
|
@@ -32,8 +37,18 @@ export interface CompileContext {
|
|
|
32
37
|
}>;
|
|
33
38
|
}>;
|
|
34
39
|
routes: CompileContextRoute[];
|
|
40
|
+
/** False when a deployment platform serves client/public assets before Elysia. */
|
|
41
|
+
serveAssets?: boolean;
|
|
35
42
|
ssgCache?: Record<string, SsgCacheEntry>;
|
|
43
|
+
/** Production HTML template embedded by filesystem-free deployment adapters. */
|
|
44
|
+
templateHtml?: string;
|
|
36
45
|
}
|
|
46
|
+
export declare function waitForPendingISRRevalidations(): Promise<void>;
|
|
47
|
+
export declare function hasPendingISRRevalidations(): boolean;
|
|
48
|
+
export declare function markExternalPrerenderRequest(request: Request): Request;
|
|
49
|
+
export declare function setRuntimeCacheProvider(provider: RuntimeCacheProvider): void;
|
|
50
|
+
export declare function setCacheTagPurger(purger: (tags: string[]) => Promise<void>): void;
|
|
51
|
+
export declare const restorePprResumeRequest: typeof restoreResumeRequest;
|
|
37
52
|
export declare function __setCompileContext(ctx: CompileContext): void;
|
|
38
53
|
/**
|
|
39
54
|
* Looks up the compile context for a (pagesDir, prefix) mount. Resolution
|