@teyik0/furin 0.2.0-alpha.2 → 0.2.0-alpha.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -0
- package/dist/adapter/bun.d.ts +3 -0
- package/dist/adapter/static.d.ts +3 -0
- package/dist/build/client.d.ts +25 -0
- package/dist/build/compile-entry.d.ts +9 -0
- package/dist/build/compile-entry.ts +109 -0
- package/dist/build/entry-template.d.ts +38 -0
- package/dist/build/entry-template.ts +156 -0
- package/dist/build/hydrate.d.ts +24 -0
- package/dist/build/index.d.ts +8 -0
- package/dist/build/index.js +8106 -0
- package/dist/build/route-types.d.ts +23 -0
- package/dist/build/scan-server.d.ts +8 -0
- package/dist/build/server-routes-entry.d.ts +13 -0
- package/dist/build/server-routes-entry.ts +36 -0
- package/dist/build/shared.d.ts +12 -0
- package/dist/build/ssg-cache.d.ts +4 -0
- package/dist/build/types.d.ts +80 -0
- package/dist/cli/config.d.ts +9 -0
- package/dist/cli/index.d.ts +2 -0
- package/dist/cli/index.js +8097 -0
- package/dist/client/boundaries.d.ts +117 -0
- package/dist/client/default-screens.d.ts +17 -0
- package/dist/client/link.d.ts +22 -0
- package/dist/client/link.js +4391 -0
- package/dist/client/router/abort.d.ts +1 -0
- package/dist/client/router/boundary-tree.d.ts +26 -0
- package/dist/client/router/context.d.ts +8 -0
- package/dist/client/router/history.d.ts +9 -0
- package/dist/client/router/index.d.ts +11 -0
- package/dist/client/router/link-utils.d.ts +53 -0
- package/dist/client/router/navigation.d.ts +10 -0
- package/dist/client/router/provider.d.ts +4 -0
- package/dist/client/router/search/index.d.ts +18 -0
- package/dist/client/router/search-store.d.ts +21 -0
- package/dist/client/router/spa-response.d.ts +58 -0
- package/dist/client/router/sync-catch-up.d.ts +29 -0
- package/dist/client/router/types.d.ts +292 -0
- package/dist/client/server-error.d.ts +12 -0
- package/dist/client/sync.d.ts +25 -0
- package/dist/client.d.ts +243 -0
- package/dist/client.js +140 -0
- package/dist/config.d.ts +57 -0
- package/dist/config.js +29 -0
- package/dist/env.d.ts +50 -0
- package/dist/furin.d.ts +77 -0
- package/dist/furin.js +8977 -0
- package/dist/plugin/index.d.ts +20 -0
- package/dist/plugin/index.js +1500 -0
- package/dist/plugin/transform-client.d.ts +10 -0
- package/dist/server/auto-invalidate/index.d.ts +4 -0
- package/dist/server/auto-invalidate/plugin.d.ts +38 -0
- package/dist/server/auto-invalidate/registry.d.ts +9 -0
- package/dist/server/auto-invalidate/runtime.d.ts +9 -0
- package/dist/server/auto-invalidate/types.d.ts +12 -0
- package/dist/server/cache/dev-loader.d.ts +28 -0
- package/dist/server/cache/index.d.ts +10 -0
- package/dist/server/cache/invalidation.d.ts +12 -0
- package/dist/server/cache/isr-ssg.d.ts +26 -0
- package/dist/server/cache/isr.d.ts +6 -0
- package/dist/server/cache/registry.d.ts +5 -0
- package/dist/server/cache/route-cache.d.ts +26 -0
- package/dist/server/cache/ssg.d.ts +5 -0
- package/dist/server/context-logger.d.ts +28 -0
- package/dist/server/dev-inspector.d.ts +89 -0
- package/dist/server/dev-page-plugin.d.ts +112 -0
- package/dist/server/internal.d.ts +35 -0
- package/dist/server/internal.js +17 -0
- package/dist/server/lang-detect.d.ts +5 -0
- package/dist/server/render/assemble.d.ts +49 -0
- package/dist/server/render/element.d.ts +24 -0
- package/dist/server/render/index.d.ts +7 -0
- package/dist/server/render/index.ts +22 -0
- package/dist/server/render/isr.d.ts +4 -0
- package/dist/server/render/loaders.d.ts +64 -0
- package/dist/server/render/not-found.d.ts +6 -0
- package/dist/server/render/shell.d.ts +39 -0
- package/dist/server/render/shell.ts +202 -0
- package/dist/server/render/ssg.d.ts +9 -0
- package/dist/server/render/ssr.d.ts +108 -0
- package/dist/server/render/template.d.ts +6 -0
- package/dist/server/router/discovery.d.ts +16 -0
- package/dist/server/router/hmr.d.ts +65 -0
- package/dist/server/router/index.d.ts +6 -0
- package/dist/server/router/index.js +27 -0
- package/dist/server/router/index.ts +28 -0
- package/dist/server/router/patterns.d.ts +40 -0
- package/dist/server/router/plugin.d.ts +21 -0
- package/dist/server/router/schemas.d.ts +59 -0
- package/dist/server/router/types.d.ts +60 -0
- package/dist/server/runtime-env.d.ts +3 -0
- package/dist/server/runtime-env.js +10 -0
- package/dist/server/sync/adapter.d.ts +62 -0
- package/dist/server/sync/config.d.ts +6 -0
- package/dist/server/sync/fingerprint.d.ts +6 -0
- package/dist/server/sync/index.d.ts +4 -0
- package/dist/server/sync/memory-adapter.d.ts +17 -0
- package/dist/server/sync/plugin.d.ts +186 -0
- package/dist/server/sync/response.d.ts +4 -0
- package/dist/server/sync/stream.d.ts +59 -0
- package/dist/shared/await.d.ts +67 -0
- package/dist/shared/deferred-ndjson.d.ts +32 -0
- package/dist/shared/digest.d.ts +16 -0
- package/dist/shared/error.d.ts +37 -0
- package/dist/shared/not-found.d.ts +19 -0
- package/dist/shared/search-params.d.ts +17 -0
- package/dist/shared/utils/ast-walk.d.ts +18 -0
- package/dist/shared/utils/index.d.ts +13 -0
- package/package.json +5 -5
- package/src/build/hydrate.ts +4 -1
- package/src/build/shared.ts +4 -3
- package/src/client/router/abort.ts +5 -0
- package/src/client/router/link-utils.ts +8 -1
- package/src/client/router/provider.tsx +130 -6
- package/src/client/router/sync-catch-up.ts +113 -0
- package/src/client/router/types.ts +5 -0
- package/src/client/sync.ts +98 -0
- package/src/client.ts +15 -1
- package/src/furin.ts +25 -4
- package/src/server/auto-invalidate/runtime.ts +3 -2
- package/src/server/dev-page-plugin.ts +15 -10
- package/src/server/render/assemble.ts +30 -3
- package/src/server/render/isr.ts +8 -2
- package/src/server/render/ssr.ts +9 -1
- package/src/server/router/plugin.ts +2 -2
- package/src/server/sync/adapter.ts +65 -0
- package/src/server/sync/config.ts +29 -0
- package/src/server/sync/fingerprint.ts +44 -0
- package/src/server/sync/index.ts +15 -0
- package/src/server/sync/memory-adapter.ts +196 -0
- package/src/server/sync/plugin.ts +200 -0
- package/src/server/sync/response.ts +77 -0
- package/src/server/sync/stream.ts +152 -0
- package/src/shared/deferred-ndjson.ts +7 -0
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import type { AnySchema } from "elysia/types";
|
|
2
|
+
import type { RuntimeRoute } from "../../client.ts";
|
|
3
|
+
import { type SearchParamsInput, type SearchRouteMetadata } from "../../shared/search-params.ts";
|
|
4
|
+
interface UnknownObject {
|
|
5
|
+
[key: string]: unknown;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Parses the `?path=` argument of `/_furin/data`, rejecting absolute /
|
|
9
|
+
* protocol-relative inputs that would let a caller smuggle a foreign origin
|
|
10
|
+
* into the synthetic loader request.
|
|
11
|
+
*
|
|
12
|
+
* Returns `{ url, pathname }` on success, or `undefined` when the input is
|
|
13
|
+
* unsafe (the caller should reply 400). `new URL(rawPath, base)` ignores the
|
|
14
|
+
* base when `rawPath` is itself absolute, so without these prefix and origin
|
|
15
|
+
* checks a value like `https://evil.com/foo` would propagate to
|
|
16
|
+
* `syntheticRequest.url`.
|
|
17
|
+
*
|
|
18
|
+
* @internal Exported for unit testing.
|
|
19
|
+
*/
|
|
20
|
+
export declare function parseDataEndpointPath(rawPath: string): {
|
|
21
|
+
url: URL;
|
|
22
|
+
pathname: string;
|
|
23
|
+
} | undefined;
|
|
24
|
+
export type ParseRouteQueryResult = {
|
|
25
|
+
ok: true;
|
|
26
|
+
query: SearchParamsInput;
|
|
27
|
+
} | {
|
|
28
|
+
errors: unknown;
|
|
29
|
+
ok: false;
|
|
30
|
+
};
|
|
31
|
+
/**
|
|
32
|
+
* Parses and validates a logical route URL's search string for the synthetic
|
|
33
|
+
* `/_furin/data` request path. This keeps SPA navigations aligned with the
|
|
34
|
+
* Elysia guard used by the full SSR route.
|
|
35
|
+
*
|
|
36
|
+
* @internal Exported for unit testing.
|
|
37
|
+
*/
|
|
38
|
+
export declare function parseRouteQuery(url: URL, schema: AnySchema | undefined): Promise<ParseRouteQueryResult>;
|
|
39
|
+
/**
|
|
40
|
+
* Merges TObject schemas from all routeChain entries for a given key.
|
|
41
|
+
* Properties are spread left-to-right (leaf wins on key conflict).
|
|
42
|
+
* Object-level options (additionalProperties, $id, description, …) are also
|
|
43
|
+
* merged with the same leaf-wins semantics so they are not silently dropped.
|
|
44
|
+
* Returns undefined when no entry in the chain defines the key.
|
|
45
|
+
*
|
|
46
|
+
* @internal Exported for unit testing.
|
|
47
|
+
*/
|
|
48
|
+
export declare function mergeRouteSchemas(routeChain: RuntimeRoute[], key: "params" | "query"): AnySchema | undefined;
|
|
49
|
+
export declare function createSearchRouteMetadata(routes: Array<{
|
|
50
|
+
pattern: string;
|
|
51
|
+
routeChain: RuntimeRoute[];
|
|
52
|
+
}>): SearchRouteMetadata[];
|
|
53
|
+
/**
|
|
54
|
+
* Applies top-level `default` values from a TypeBox TObject schema to a
|
|
55
|
+
* values record. Used in the `/_furin/data` endpoint so loaders see the same
|
|
56
|
+
* defaulted query objects that the SSR path produces via Elysia's guard.
|
|
57
|
+
*/
|
|
58
|
+
export declare function applySchemaDefaults(schema: UnknownObject | undefined, values: UnknownObject): UnknownObject;
|
|
59
|
+
export {};
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import type { RuntimePage, RuntimeRoute } from "../../client.ts";
|
|
2
|
+
import type { ErrorComponent } from "../../shared/error.ts";
|
|
3
|
+
import type { NotFoundComponent } from "../../shared/not-found.ts";
|
|
4
|
+
/**
|
|
5
|
+
* A single directory-scoped boundary declaration.
|
|
6
|
+
*
|
|
7
|
+
* Each entry represents ONE directory on the path from `pagesDir` to the page
|
|
8
|
+
* file. `error` / `notFound` hold the components defined IN THAT DIRECTORY
|
|
9
|
+
* only — never inherited from a parent. This 1:1 tie between directory and
|
|
10
|
+
* entry is what lets the render layer insert React error boundaries at the
|
|
11
|
+
* exact nesting level where the user authored them (Next.js app-router model).
|
|
12
|
+
*/
|
|
13
|
+
export interface SegmentBoundary {
|
|
14
|
+
/** 0 = `pagesDir`; increments with each nested subdirectory. */
|
|
15
|
+
depth: number;
|
|
16
|
+
error?: ErrorComponent;
|
|
17
|
+
/**
|
|
18
|
+
* Absolute path to the `error.tsx` module, when present. Carried alongside
|
|
19
|
+
* the component so the client hydrate entry can emit a static `import`
|
|
20
|
+
* statement for each unique convention file — a component reference alone
|
|
21
|
+
* can't survive the server→client boundary.
|
|
22
|
+
*/
|
|
23
|
+
errorPath?: string;
|
|
24
|
+
notFound?: NotFoundComponent;
|
|
25
|
+
/** Absolute path to the `not-found.tsx` module, when present. */
|
|
26
|
+
notFoundPath?: string;
|
|
27
|
+
/** Absolute directory path. */
|
|
28
|
+
path: string;
|
|
29
|
+
}
|
|
30
|
+
export interface ResolvedRoute {
|
|
31
|
+
error?: ErrorComponent;
|
|
32
|
+
isrCache?: {
|
|
33
|
+
html: string;
|
|
34
|
+
generatedAt: number;
|
|
35
|
+
revalidate: number;
|
|
36
|
+
};
|
|
37
|
+
mode: "ssr" | "ssg" | "isr";
|
|
38
|
+
notFound?: NotFoundComponent;
|
|
39
|
+
page: RuntimePage;
|
|
40
|
+
path: string;
|
|
41
|
+
pattern: string;
|
|
42
|
+
routeChain: RuntimeRoute[];
|
|
43
|
+
/**
|
|
44
|
+
* Per-directory boundary chain, ordered shallow → deep. Only directories
|
|
45
|
+
* that DECLARE at least one of `error.tsx` / `not-found.tsx` are included;
|
|
46
|
+
* directories without conventions are skipped. Empty when no conventions
|
|
47
|
+
* exist anywhere in the path.
|
|
48
|
+
*/
|
|
49
|
+
segmentBoundaries: SegmentBoundary[];
|
|
50
|
+
ssgHtml?: string;
|
|
51
|
+
tags?: string[];
|
|
52
|
+
}
|
|
53
|
+
export interface RootLayout {
|
|
54
|
+
error?: ErrorComponent;
|
|
55
|
+
errorPath?: string;
|
|
56
|
+
notFound?: NotFoundComponent;
|
|
57
|
+
notFoundPath?: string;
|
|
58
|
+
path: string;
|
|
59
|
+
route: RuntimeRoute;
|
|
60
|
+
}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
export interface StoredResponse {
|
|
2
|
+
body: Uint8Array;
|
|
3
|
+
headers: ReadonlyArray<readonly [string, string]>;
|
|
4
|
+
status: number;
|
|
5
|
+
}
|
|
6
|
+
export interface BeginMutationInput {
|
|
7
|
+
fingerprint: string;
|
|
8
|
+
key: string;
|
|
9
|
+
principal: string;
|
|
10
|
+
}
|
|
11
|
+
export type BeginMutationResult = {
|
|
12
|
+
kind: "execute";
|
|
13
|
+
mutationId: string;
|
|
14
|
+
} | {
|
|
15
|
+
kind: "replay";
|
|
16
|
+
response: StoredResponse;
|
|
17
|
+
} | {
|
|
18
|
+
kind: "conflict";
|
|
19
|
+
reason: "in-progress" | "payload-mismatch";
|
|
20
|
+
} | {
|
|
21
|
+
kind: "unavailable";
|
|
22
|
+
};
|
|
23
|
+
export interface CommitMutationInput {
|
|
24
|
+
mutationId: string;
|
|
25
|
+
response: StoredResponse;
|
|
26
|
+
}
|
|
27
|
+
export interface AbortMutationInput {
|
|
28
|
+
mutationId: string;
|
|
29
|
+
}
|
|
30
|
+
export interface SyncChange {
|
|
31
|
+
cursor: string;
|
|
32
|
+
invalidations: readonly string[];
|
|
33
|
+
}
|
|
34
|
+
export interface AppendChangesInput {
|
|
35
|
+
invalidations: readonly string[];
|
|
36
|
+
path: string;
|
|
37
|
+
}
|
|
38
|
+
export interface AppendChangesResult {
|
|
39
|
+
change: SyncChange;
|
|
40
|
+
}
|
|
41
|
+
export interface ReadChangesInput {
|
|
42
|
+
after: string | undefined;
|
|
43
|
+
limit: number;
|
|
44
|
+
path: string;
|
|
45
|
+
}
|
|
46
|
+
export interface ChangePage {
|
|
47
|
+
changes: readonly SyncChange[];
|
|
48
|
+
cursor: string;
|
|
49
|
+
hasMore: boolean;
|
|
50
|
+
reset: boolean;
|
|
51
|
+
}
|
|
52
|
+
export type SyncChangeListener = (change: SyncChange) => void;
|
|
53
|
+
type MaybePromise<T> = Promise<T> | T;
|
|
54
|
+
export interface SyncAdapter {
|
|
55
|
+
abortMutation(input: AbortMutationInput): MaybePromise<void>;
|
|
56
|
+
appendChanges(input: AppendChangesInput): MaybePromise<AppendChangesResult>;
|
|
57
|
+
beginMutation(input: BeginMutationInput): MaybePromise<BeginMutationResult>;
|
|
58
|
+
commitMutation(input: CommitMutationInput): MaybePromise<void>;
|
|
59
|
+
readChanges(input: ReadChangesInput): MaybePromise<ChangePage>;
|
|
60
|
+
subscribe(path: string, listener: SyncChangeListener): () => void;
|
|
61
|
+
}
|
|
62
|
+
export {};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export type FurinSyncOption = boolean | {
|
|
2
|
+
streamPath?: string;
|
|
3
|
+
};
|
|
4
|
+
export declare function resolveSyncStreamPath(sync: FurinSyncOption | undefined): string | undefined;
|
|
5
|
+
export declare function getSyncStreamPath(): string | undefined;
|
|
6
|
+
export declare function runWithSyncStreamPath<T>(path: string | undefined, fn: () => T): T;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export type { FurinSyncOption } from "./config.ts";
|
|
2
|
+
export { getSyncStreamPath, resolveSyncStreamPath, runWithSyncStreamPath, } from "./config.ts";
|
|
3
|
+
export { furinSync, type SyncInput, type SyncRouteOption } from "./plugin.ts";
|
|
4
|
+
export { __resetSyncState, createSyncStreamPlugin, publishSyncInvalidation, type SyncChange, type SyncChangePage, } from "./stream.ts";
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { AbortMutationInput, AppendChangesInput, AppendChangesResult, BeginMutationInput, BeginMutationResult, ChangePage, CommitMutationInput, ReadChangesInput, SyncAdapter, SyncChangeListener } from "./adapter.ts";
|
|
2
|
+
export declare class MemorySyncAdapter implements SyncAdapter {
|
|
3
|
+
private readonly changes;
|
|
4
|
+
private readonly mutationKeys;
|
|
5
|
+
private readonly mutations;
|
|
6
|
+
beginMutation(input: BeginMutationInput): BeginMutationResult;
|
|
7
|
+
commitMutation(input: CommitMutationInput): void;
|
|
8
|
+
abortMutation(input: AbortMutationInput): void;
|
|
9
|
+
appendChanges(input: AppendChangesInput): AppendChangesResult;
|
|
10
|
+
readChanges(input: ReadChangesInput): ChangePage;
|
|
11
|
+
subscribe(path: string, listener: SyncChangeListener): () => void;
|
|
12
|
+
reset(): void;
|
|
13
|
+
private evictMutations;
|
|
14
|
+
private deleteMutation;
|
|
15
|
+
private getChangeState;
|
|
16
|
+
}
|
|
17
|
+
export declare const memorySyncAdapter: MemorySyncAdapter;
|
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
import { Elysia } from "elysia";
|
|
2
|
+
import type { InvalidationInput } from "../auto-invalidate/types.ts";
|
|
3
|
+
export type SyncRouteOption = false | InvalidationInput | {
|
|
4
|
+
invalidate: InvalidationInput;
|
|
5
|
+
};
|
|
6
|
+
/** @deprecated Use SyncRouteOption. */
|
|
7
|
+
export type SyncInput = Exclude<SyncRouteOption, false>;
|
|
8
|
+
export declare function furinSync(): Elysia<"", {
|
|
9
|
+
decorator: {};
|
|
10
|
+
store: {};
|
|
11
|
+
derive: {};
|
|
12
|
+
resolve: {};
|
|
13
|
+
}, {
|
|
14
|
+
typebox: {};
|
|
15
|
+
error: {};
|
|
16
|
+
}, {
|
|
17
|
+
schema: {};
|
|
18
|
+
standaloneSchema: {};
|
|
19
|
+
macro: Partial<{
|
|
20
|
+
readonly sync: SyncRouteOption;
|
|
21
|
+
}>;
|
|
22
|
+
macroFn: {
|
|
23
|
+
readonly sync: (input: SyncRouteOption) => {
|
|
24
|
+
readonly transform: ({ request }: {
|
|
25
|
+
body: unknown;
|
|
26
|
+
query: Record<string, string>;
|
|
27
|
+
params: {};
|
|
28
|
+
headers: Record<string, string | undefined>;
|
|
29
|
+
cookie: Record<string, import("elysia").Cookie<unknown>>;
|
|
30
|
+
server: import("elysia/universal/server").Server | null;
|
|
31
|
+
redirect: import("elysia").redirect;
|
|
32
|
+
set: {
|
|
33
|
+
headers: import("elysia").HTTPHeaders;
|
|
34
|
+
status?: number | keyof import("elysia").StatusMap;
|
|
35
|
+
redirect?: string;
|
|
36
|
+
cookie?: Record<string, import("elysia/cookies").ElysiaCookie>;
|
|
37
|
+
};
|
|
38
|
+
path: string;
|
|
39
|
+
route: string;
|
|
40
|
+
request: Request;
|
|
41
|
+
store: {};
|
|
42
|
+
status: <const Code extends number | keyof import("elysia").StatusMap, const T = Code extends 301 | 302 | 303 | 307 | 308 | 200 | 300 | 404 | 500 | 304 | 400 | 422 | 100 | 101 | 102 | 103 | 201 | 202 | 203 | 204 | 205 | 206 | 207 | 208 | 401 | 402 | 403 | 405 | 406 | 407 | 408 | 409 | 410 | 411 | 412 | 413 | 414 | 415 | 416 | 417 | 418 | 420 | 421 | 423 | 424 | 425 | 426 | 428 | 429 | 431 | 451 | 501 | 502 | 503 | 504 | 505 | 506 | 507 | 508 | 510 | 511 ? {
|
|
43
|
+
readonly 100: "Continue";
|
|
44
|
+
readonly 101: "Switching Protocols";
|
|
45
|
+
readonly 102: "Processing";
|
|
46
|
+
readonly 103: "Early Hints";
|
|
47
|
+
readonly 200: "OK";
|
|
48
|
+
readonly 201: "Created";
|
|
49
|
+
readonly 202: "Accepted";
|
|
50
|
+
readonly 203: "Non-Authoritative Information";
|
|
51
|
+
readonly 204: "No Content";
|
|
52
|
+
readonly 205: "Reset Content";
|
|
53
|
+
readonly 206: "Partial Content";
|
|
54
|
+
readonly 207: "Multi-Status";
|
|
55
|
+
readonly 208: "Already Reported";
|
|
56
|
+
readonly 300: "Multiple Choices";
|
|
57
|
+
readonly 301: "Moved Permanently";
|
|
58
|
+
readonly 302: "Found";
|
|
59
|
+
readonly 303: "See Other";
|
|
60
|
+
readonly 304: "Not Modified";
|
|
61
|
+
readonly 307: "Temporary Redirect";
|
|
62
|
+
readonly 308: "Permanent Redirect";
|
|
63
|
+
readonly 400: "Bad Request";
|
|
64
|
+
readonly 401: "Unauthorized";
|
|
65
|
+
readonly 402: "Payment Required";
|
|
66
|
+
readonly 403: "Forbidden";
|
|
67
|
+
readonly 404: "Not Found";
|
|
68
|
+
readonly 405: "Method Not Allowed";
|
|
69
|
+
readonly 406: "Not Acceptable";
|
|
70
|
+
readonly 407: "Proxy Authentication Required";
|
|
71
|
+
readonly 408: "Request Timeout";
|
|
72
|
+
readonly 409: "Conflict";
|
|
73
|
+
readonly 410: "Gone";
|
|
74
|
+
readonly 411: "Length Required";
|
|
75
|
+
readonly 412: "Precondition Failed";
|
|
76
|
+
readonly 413: "Payload Too Large";
|
|
77
|
+
readonly 414: "URI Too Long";
|
|
78
|
+
readonly 415: "Unsupported Media Type";
|
|
79
|
+
readonly 416: "Range Not Satisfiable";
|
|
80
|
+
readonly 417: "Expectation Failed";
|
|
81
|
+
readonly 418: "I'm a teapot";
|
|
82
|
+
readonly 420: "Enhance Your Calm";
|
|
83
|
+
readonly 421: "Misdirected Request";
|
|
84
|
+
readonly 422: "Unprocessable Content";
|
|
85
|
+
readonly 423: "Locked";
|
|
86
|
+
readonly 424: "Failed Dependency";
|
|
87
|
+
readonly 425: "Too Early";
|
|
88
|
+
readonly 426: "Upgrade Required";
|
|
89
|
+
readonly 428: "Precondition Required";
|
|
90
|
+
readonly 429: "Too Many Requests";
|
|
91
|
+
readonly 431: "Request Header Fields Too Large";
|
|
92
|
+
readonly 451: "Unavailable For Legal Reasons";
|
|
93
|
+
readonly 500: "Internal Server Error";
|
|
94
|
+
readonly 501: "Not Implemented";
|
|
95
|
+
readonly 502: "Bad Gateway";
|
|
96
|
+
readonly 503: "Service Unavailable";
|
|
97
|
+
readonly 504: "Gateway Timeout";
|
|
98
|
+
readonly 505: "HTTP Version Not Supported";
|
|
99
|
+
readonly 506: "Variant Also Negotiates";
|
|
100
|
+
readonly 507: "Insufficient Storage";
|
|
101
|
+
readonly 508: "Loop Detected";
|
|
102
|
+
readonly 510: "Not Extended";
|
|
103
|
+
readonly 511: "Network Authentication Required";
|
|
104
|
+
}[Code] : Code>(code: Code, response?: T) => import("elysia").ElysiaCustomStatusResponse<Code, T, Code extends "Continue" | "Switching Protocols" | "Processing" | "Early Hints" | "OK" | "Created" | "Accepted" | "Non-Authoritative Information" | "No Content" | "Reset Content" | "Partial Content" | "Multi-Status" | "Already Reported" | "Multiple Choices" | "Moved Permanently" | "Found" | "See Other" | "Not Modified" | "Temporary Redirect" | "Permanent Redirect" | "Bad Request" | "Unauthorized" | "Payment Required" | "Forbidden" | "Not Found" | "Method Not Allowed" | "Not Acceptable" | "Proxy Authentication Required" | "Request Timeout" | "Conflict" | "Gone" | "Length Required" | "Precondition Failed" | "Payload Too Large" | "URI Too Long" | "Unsupported Media Type" | "Range Not Satisfiable" | "Expectation Failed" | "I'm a teapot" | "Enhance Your Calm" | "Misdirected Request" | "Unprocessable Content" | "Locked" | "Failed Dependency" | "Too Early" | "Upgrade Required" | "Precondition Required" | "Too Many Requests" | "Request Header Fields Too Large" | "Unavailable For Legal Reasons" | "Internal Server Error" | "Not Implemented" | "Bad Gateway" | "Service Unavailable" | "Gateway Timeout" | "HTTP Version Not Supported" | "Variant Also Negotiates" | "Insufficient Storage" | "Loop Detected" | "Not Extended" | "Network Authentication Required" ? {
|
|
105
|
+
readonly Continue: 100;
|
|
106
|
+
readonly "Switching Protocols": 101;
|
|
107
|
+
readonly Processing: 102;
|
|
108
|
+
readonly "Early Hints": 103;
|
|
109
|
+
readonly OK: 200;
|
|
110
|
+
readonly Created: 201;
|
|
111
|
+
readonly Accepted: 202;
|
|
112
|
+
readonly "Non-Authoritative Information": 203;
|
|
113
|
+
readonly "No Content": 204;
|
|
114
|
+
readonly "Reset Content": 205;
|
|
115
|
+
readonly "Partial Content": 206;
|
|
116
|
+
readonly "Multi-Status": 207;
|
|
117
|
+
readonly "Already Reported": 208;
|
|
118
|
+
readonly "Multiple Choices": 300;
|
|
119
|
+
readonly "Moved Permanently": 301;
|
|
120
|
+
readonly Found: 302;
|
|
121
|
+
readonly "See Other": 303;
|
|
122
|
+
readonly "Not Modified": 304;
|
|
123
|
+
readonly "Temporary Redirect": 307;
|
|
124
|
+
readonly "Permanent Redirect": 308;
|
|
125
|
+
readonly "Bad Request": 400;
|
|
126
|
+
readonly Unauthorized: 401;
|
|
127
|
+
readonly "Payment Required": 402;
|
|
128
|
+
readonly Forbidden: 403;
|
|
129
|
+
readonly "Not Found": 404;
|
|
130
|
+
readonly "Method Not Allowed": 405;
|
|
131
|
+
readonly "Not Acceptable": 406;
|
|
132
|
+
readonly "Proxy Authentication Required": 407;
|
|
133
|
+
readonly "Request Timeout": 408;
|
|
134
|
+
readonly Conflict: 409;
|
|
135
|
+
readonly Gone: 410;
|
|
136
|
+
readonly "Length Required": 411;
|
|
137
|
+
readonly "Precondition Failed": 412;
|
|
138
|
+
readonly "Payload Too Large": 413;
|
|
139
|
+
readonly "URI Too Long": 414;
|
|
140
|
+
readonly "Unsupported Media Type": 415;
|
|
141
|
+
readonly "Range Not Satisfiable": 416;
|
|
142
|
+
readonly "Expectation Failed": 417;
|
|
143
|
+
readonly "I'm a teapot": 418;
|
|
144
|
+
readonly "Enhance Your Calm": 420;
|
|
145
|
+
readonly "Misdirected Request": 421;
|
|
146
|
+
readonly "Unprocessable Content": 422;
|
|
147
|
+
readonly Locked: 423;
|
|
148
|
+
readonly "Failed Dependency": 424;
|
|
149
|
+
readonly "Too Early": 425;
|
|
150
|
+
readonly "Upgrade Required": 426;
|
|
151
|
+
readonly "Precondition Required": 428;
|
|
152
|
+
readonly "Too Many Requests": 429;
|
|
153
|
+
readonly "Request Header Fields Too Large": 431;
|
|
154
|
+
readonly "Unavailable For Legal Reasons": 451;
|
|
155
|
+
readonly "Internal Server Error": 500;
|
|
156
|
+
readonly "Not Implemented": 501;
|
|
157
|
+
readonly "Bad Gateway": 502;
|
|
158
|
+
readonly "Service Unavailable": 503;
|
|
159
|
+
readonly "Gateway Timeout": 504;
|
|
160
|
+
readonly "HTTP Version Not Supported": 505;
|
|
161
|
+
readonly "Variant Also Negotiates": 506;
|
|
162
|
+
readonly "Insufficient Storage": 507;
|
|
163
|
+
readonly "Loop Detected": 508;
|
|
164
|
+
readonly "Not Extended": 510;
|
|
165
|
+
readonly "Network Authentication Required": 511;
|
|
166
|
+
}[Code] : Code>;
|
|
167
|
+
}) => void;
|
|
168
|
+
};
|
|
169
|
+
};
|
|
170
|
+
parser: {};
|
|
171
|
+
response: {
|
|
172
|
+
200: Response;
|
|
173
|
+
};
|
|
174
|
+
}, {}, {
|
|
175
|
+
derive: {};
|
|
176
|
+
resolve: {};
|
|
177
|
+
schema: {};
|
|
178
|
+
standaloneSchema: {};
|
|
179
|
+
response: {};
|
|
180
|
+
}, {
|
|
181
|
+
derive: {};
|
|
182
|
+
resolve: {};
|
|
183
|
+
schema: {};
|
|
184
|
+
standaloneSchema: {};
|
|
185
|
+
response: {};
|
|
186
|
+
}>;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { type Context } from "elysia";
|
|
2
|
+
import type { StoredResponse } from "./adapter.ts";
|
|
3
|
+
export declare function storeResponse(responseValue: unknown, set: Context["set"]): Promise<StoredResponse>;
|
|
4
|
+
export declare function replayResponse(stored: StoredResponse): Response;
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { Elysia } from "elysia";
|
|
2
|
+
export type { ChangePage as SyncChangePage, SyncChange } from "./adapter.ts";
|
|
3
|
+
export declare function publishSyncInvalidation(invalidations: readonly string[]): void;
|
|
4
|
+
export declare function createSyncStreamPlugin(path?: string): Elysia<"", {
|
|
5
|
+
decorator: {};
|
|
6
|
+
store: {};
|
|
7
|
+
derive: {};
|
|
8
|
+
resolve: {};
|
|
9
|
+
}, {
|
|
10
|
+
typebox: {};
|
|
11
|
+
error: {};
|
|
12
|
+
}, {
|
|
13
|
+
schema: {};
|
|
14
|
+
standaloneSchema: {};
|
|
15
|
+
macro: {};
|
|
16
|
+
macroFn: {};
|
|
17
|
+
parser: {};
|
|
18
|
+
response: {};
|
|
19
|
+
}, {
|
|
20
|
+
[x: string]: {
|
|
21
|
+
changes: {
|
|
22
|
+
get: {
|
|
23
|
+
body: unknown;
|
|
24
|
+
params: {};
|
|
25
|
+
query: unknown;
|
|
26
|
+
headers: unknown;
|
|
27
|
+
response: {
|
|
28
|
+
200: Response | import("./adapter.ts").ChangePage;
|
|
29
|
+
};
|
|
30
|
+
};
|
|
31
|
+
};
|
|
32
|
+
};
|
|
33
|
+
} & {
|
|
34
|
+
[x: string]: {
|
|
35
|
+
get: {
|
|
36
|
+
body: unknown;
|
|
37
|
+
params: {};
|
|
38
|
+
query: unknown;
|
|
39
|
+
headers: unknown;
|
|
40
|
+
response: {
|
|
41
|
+
200: Response;
|
|
42
|
+
};
|
|
43
|
+
};
|
|
44
|
+
};
|
|
45
|
+
}, {
|
|
46
|
+
derive: {};
|
|
47
|
+
resolve: {};
|
|
48
|
+
schema: {};
|
|
49
|
+
standaloneSchema: {};
|
|
50
|
+
response: {};
|
|
51
|
+
}, {
|
|
52
|
+
derive: {};
|
|
53
|
+
resolve: {};
|
|
54
|
+
schema: {};
|
|
55
|
+
standaloneSchema: {};
|
|
56
|
+
response: {};
|
|
57
|
+
}>;
|
|
58
|
+
/** @internal — resets process-local sync state between tests. */
|
|
59
|
+
export declare function __resetSyncState(): void;
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { type ReactNode } from "react";
|
|
2
|
+
/**
|
|
3
|
+
* Context used to pass the caught error from `AsyncErrorBoundary` down to
|
|
4
|
+
* `errorElement` children so they can read it via `useAsyncError()`.
|
|
5
|
+
*/
|
|
6
|
+
export declare const AsyncErrorContext: import("react").Context<unknown>;
|
|
7
|
+
/**
|
|
8
|
+
* Inside an `<Await errorElement={...}>`, returns the error that caused the
|
|
9
|
+
* deferred Promise to reject. Throws outside of an error-boundary subtree.
|
|
10
|
+
*/
|
|
11
|
+
export declare function useAsyncError(): unknown;
|
|
12
|
+
/**
|
|
13
|
+
* Inside a resolved `<Await>`, returns the resolved value via React 19's
|
|
14
|
+
* `use()`. Can be used as an alternative to the render-prop children API.
|
|
15
|
+
*
|
|
16
|
+
* Must be used inside a component that is rendered as children of `<Await>`.
|
|
17
|
+
*/
|
|
18
|
+
export declare function useAsyncValue<T>(): T;
|
|
19
|
+
export interface AwaitProps<T> {
|
|
20
|
+
/**
|
|
21
|
+
* Render-prop children: called with the resolved value once the Promise
|
|
22
|
+
* settles. The returned `ReactNode` is rendered inside a Suspense boundary.
|
|
23
|
+
*
|
|
24
|
+
* Marked optional here so `createElement(Await, props, renderFn)` is
|
|
25
|
+
* accepted by TypeScript — the 3rd argument to `createElement` becomes
|
|
26
|
+
* `children` at runtime and is always required for correct behaviour.
|
|
27
|
+
*/
|
|
28
|
+
children?: (value: T) => ReactNode;
|
|
29
|
+
/**
|
|
30
|
+
* Rendered when the Promise rejects. Inside this subtree, `useAsyncError()`
|
|
31
|
+
* returns the rejection reason. When omitted the error propagates up to the
|
|
32
|
+
* next React error boundary.
|
|
33
|
+
*/
|
|
34
|
+
errorElement?: ReactNode;
|
|
35
|
+
/**
|
|
36
|
+
* The deferred Promise to await. Passed as a prop so React's `use()` can
|
|
37
|
+
* suspend the boundary until it resolves. This is the same Promise object
|
|
38
|
+
* that the loader returned inside `defer()`.
|
|
39
|
+
*/
|
|
40
|
+
resolve: Promise<T>;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Deferred-data boundary component. Uses React 19's `use()` to suspend the
|
|
44
|
+
* render until `resolve` settles, then calls the render-prop `children` with
|
|
45
|
+
* the resolved value.
|
|
46
|
+
*
|
|
47
|
+
* Wrap with `<Suspense fallback={…}>` to show a loading indicator while the
|
|
48
|
+
* Promise is pending.
|
|
49
|
+
*
|
|
50
|
+
* @example
|
|
51
|
+
* ```tsx
|
|
52
|
+
* export default route.page({
|
|
53
|
+
* loader: () => defer({ board: "x", stats: fetchStats() }),
|
|
54
|
+
* component: ({ board, stats }) => (
|
|
55
|
+
* <div>
|
|
56
|
+
* <h1>{board}</h1>
|
|
57
|
+
* <Suspense fallback={<Spinner />}>
|
|
58
|
+
* <Await resolve={stats}>
|
|
59
|
+
* {(s) => <StatsBar stats={s} />}
|
|
60
|
+
* </Await>
|
|
61
|
+
* </Suspense>
|
|
62
|
+
* </div>
|
|
63
|
+
* ),
|
|
64
|
+
* });
|
|
65
|
+
* ```
|
|
66
|
+
*/
|
|
67
|
+
export declare function Await<T>({ resolve, errorElement, children }: AwaitProps<T>): ReactNode;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Result returned by `parseDeferredNdjson`.
|
|
3
|
+
*/
|
|
4
|
+
export interface DeferredNdjsonResult {
|
|
5
|
+
/**
|
|
6
|
+
* Deferred promises keyed by their field name. Each Promise resolves (or
|
|
7
|
+
* rejects) once the corresponding data is available. In the SSR case the
|
|
8
|
+
* promises are already settled (serialised by `toCrossJSONAsync`). For
|
|
9
|
+
* streaming endpoints they will settle as the server flushes resolution
|
|
10
|
+
* chunks.
|
|
11
|
+
*/
|
|
12
|
+
deferredPromises: Record<string, Promise<unknown>>;
|
|
13
|
+
/** Scalar/sync values from the loader — available immediately. */
|
|
14
|
+
syncData: Record<string, unknown>;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Parses an NDJSON stream produced by `/_furin/data`.
|
|
18
|
+
*
|
|
19
|
+
* Protocol (v1 — single-line, all-resolved):
|
|
20
|
+
* Line 0 — `JSON.stringify(await toCrossJSONAsync(loaderData))`
|
|
21
|
+
*
|
|
22
|
+
* The CrossJSON node is deserialised with `fromCrossJSON`. Values that are
|
|
23
|
+
* Promises (seroval type 12) land in `deferredPromises`; everything else
|
|
24
|
+
* lands in `syncData`.
|
|
25
|
+
*
|
|
26
|
+
* @param stream - A `ReadableStream<Uint8Array>` from `fetch().body`.
|
|
27
|
+
* @param signal - AbortSignal that, when aborted, cancels the reader and
|
|
28
|
+
* rejects every still-pending deferred promise with an
|
|
29
|
+
* `AbortError`. Pass `undefined` to opt out (no implicit
|
|
30
|
+
* default — see CLAUDE.md).
|
|
31
|
+
*/
|
|
32
|
+
export declare function parseDeferredNdjson(stream: ReadableStream<Uint8Array>, signal: AbortSignal | undefined): Promise<DeferredNdjsonResult>;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Computes a deterministic, opaque 10-hex-character digest for an error.
|
|
3
|
+
*
|
|
4
|
+
* Purpose: render this digest in client-facing error UIs (e.g. `Error ID:
|
|
5
|
+
* a3f2b9c1d8`) and log the same digest alongside the full stack on the server,
|
|
6
|
+
* so support can correlate user reports with server logs without leaking stack
|
|
7
|
+
* traces or sensitive message content to the browser.
|
|
8
|
+
*
|
|
9
|
+
* Deterministic: identical error message + stack ⇒ identical digest across
|
|
10
|
+
* restarts, processes, and environments (server + client).
|
|
11
|
+
*
|
|
12
|
+
* Uses a pure-JS 53-bit hash so the function works identically in Bun and in
|
|
13
|
+
* the browser — `computeErrorDigest` is called from `FurinErrorBoundary`, which
|
|
14
|
+
* runs on both sides.
|
|
15
|
+
*/
|
|
16
|
+
export declare function computeErrorDigest(err: unknown): string;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import type { FC } from "react";
|
|
2
|
+
export interface ErrorProps {
|
|
3
|
+
error: {
|
|
4
|
+
/** Safe user-facing message. */
|
|
5
|
+
message: string;
|
|
6
|
+
/**
|
|
7
|
+
* Opaque 10-hex-char hash of the original error. The same digest appears
|
|
8
|
+
* in the server logs next to the full stack trace, so support can
|
|
9
|
+
* correlate a user-reported error ID with server-side diagnostics
|
|
10
|
+
* without leaking stack traces to the browser.
|
|
11
|
+
*/
|
|
12
|
+
digest: string;
|
|
13
|
+
/**
|
|
14
|
+
* HTTP status associated with the error.
|
|
15
|
+
* - For thrown `Response` objects with a 4xx/5xx status: the response's
|
|
16
|
+
* status (e.g. 401, 403, 404, 500).
|
|
17
|
+
* - For all other errors (thrown `Error`, non-Error throws, shell-render
|
|
18
|
+
* crashes): always `500`.
|
|
19
|
+
*
|
|
20
|
+
* Always present so consumers never need a `?? 500` fallback. Note that
|
|
21
|
+
* `prepared.status` is honoured ONLY for loader-time errors. If a Suspense
|
|
22
|
+
* boundary throws AFTER the SSR shell has flushed (i.e. during streaming),
|
|
23
|
+
* the HTTP status cannot be changed and the user-visible status here may
|
|
24
|
+
* differ from the actual response code.
|
|
25
|
+
*/
|
|
26
|
+
status: number;
|
|
27
|
+
};
|
|
28
|
+
/**
|
|
29
|
+
* Clears the nearest FurinErrorBoundary's error state, remounting its
|
|
30
|
+
* children. On the client this re-runs the route's loader; on the server
|
|
31
|
+
* it's a no-op (the request has already produced output by the time
|
|
32
|
+
* `reset` could run).
|
|
33
|
+
*/
|
|
34
|
+
reset: () => void;
|
|
35
|
+
}
|
|
36
|
+
export type ErrorComponent = FC<ErrorProps>;
|
|
37
|
+
export declare function getPublicErrorMessage(error: Error | unknown): string;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { FC } from "react";
|
|
2
|
+
export interface NotFoundOptions {
|
|
3
|
+
data?: unknown;
|
|
4
|
+
message?: string;
|
|
5
|
+
}
|
|
6
|
+
export interface NotFoundProps {
|
|
7
|
+
error: {
|
|
8
|
+
message?: string;
|
|
9
|
+
data?: unknown;
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
export type NotFoundComponent = FC<NotFoundProps>;
|
|
13
|
+
export declare class FurinNotFoundError extends Error {
|
|
14
|
+
readonly __furinBrand: "FURIN_NOT_FOUND";
|
|
15
|
+
readonly data: unknown;
|
|
16
|
+
constructor(options: NotFoundOptions | undefined);
|
|
17
|
+
}
|
|
18
|
+
export declare function notFound(options: NotFoundOptions | undefined): never;
|
|
19
|
+
export declare function isNotFoundError(err: unknown): err is FurinNotFoundError;
|