@teyik0/furin 0.2.0-alpha.2 → 0.2.0-alpha.3
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/LICENSE +21 -21
- package/README.md +33 -33
- 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 +4244 -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/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 +8693 -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/config.d.ts +6 -0
- package/dist/server/sync/index.d.ts +4 -0
- package/dist/server/sync/plugin.d.ts +369 -0
- package/dist/server/sync/stream.d.ts +47 -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/adapter/README.md +13 -13
- package/src/build/client.ts +152 -152
- package/src/build/compile-entry.ts +109 -109
- package/src/build/entry-template.ts +156 -156
- package/src/build/hydrate.ts +340 -337
- package/src/build/index.ts +152 -152
- package/src/build/route-types.ts +145 -145
- package/src/build/scan-server.ts +95 -95
- package/src/build/server-routes-entry.ts +36 -36
- package/src/build/shared.ts +80 -79
- package/src/build/ssg-cache.ts +32 -32
- package/src/build/types.ts +89 -89
- package/src/client/router/link-utils.ts +184 -177
- package/src/client/router/provider.tsx +804 -759
- package/src/client/router/types.ts +276 -271
- package/src/client/sync.ts +98 -0
- package/src/client.ts +369 -355
- package/src/furin.ts +465 -444
- package/src/server/auto-invalidate/runtime.ts +134 -133
- package/src/server/dev-page-plugin.ts +454 -449
- package/src/server/render/assemble.ts +160 -133
- package/src/server/render/isr.ts +323 -317
- package/src/server/render/ssr.ts +585 -583
- package/src/server/router/plugin.ts +384 -384
- package/src/server/sync/config.ts +29 -0
- package/src/server/sync/index.ts +14 -0
- package/src/server/sync/plugin.ts +108 -0
- package/src/server/sync/stream.ts +144 -0
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
import { Component, type ReactNode } from "react";
|
|
2
|
+
import { type ErrorComponent } from "../shared/error.ts";
|
|
3
|
+
import { type NotFoundComponent } from "../shared/not-found.ts";
|
|
4
|
+
interface ErrorBoundaryProps {
|
|
5
|
+
children: ReactNode;
|
|
6
|
+
/**
|
|
7
|
+
* Server-provided digest for an error rendered server-side. Honoured only
|
|
8
|
+
* for the FIRST error this boundary surfaces post-hydration — i.e. when the
|
|
9
|
+
* latched error is plausibly the same one the server already logged. After
|
|
10
|
+
* any reset, or when subsequent client-side errors are caught, the boundary
|
|
11
|
+
* computes a fresh digest from the actual caught error so distinct failures
|
|
12
|
+
* keep distinct IDs.
|
|
13
|
+
*/
|
|
14
|
+
digest?: string;
|
|
15
|
+
/** Component rendered when an error is caught. Omit to use the built-in default. */
|
|
16
|
+
fallback?: ErrorComponent;
|
|
17
|
+
/**
|
|
18
|
+
* Invoked AFTER the boundary has cleared its local error state. Slice 7
|
|
19
|
+
* wires this to `router.navigate(currentHref, { force: true })` so the
|
|
20
|
+
* loader re-runs.
|
|
21
|
+
*/
|
|
22
|
+
onReset?: () => void;
|
|
23
|
+
/**
|
|
24
|
+
* When this value changes the boundary clears its error state, effectively
|
|
25
|
+
* retrying the render of `children`. Slice 7 drives this from router
|
|
26
|
+
* navigation success.
|
|
27
|
+
*/
|
|
28
|
+
resetKey?: string | number;
|
|
29
|
+
}
|
|
30
|
+
interface ErrorBoundaryState {
|
|
31
|
+
/**
|
|
32
|
+
* Digest computed at the moment the error was latched. Stored in state so
|
|
33
|
+
* each distinct caught error gets its own ID, instead of all of them
|
|
34
|
+
* inheriting the server-provided `digest` prop.
|
|
35
|
+
*/
|
|
36
|
+
digest: string | null;
|
|
37
|
+
/** Unmount/remount counter — bumped on reset to force React to discard
|
|
38
|
+
* the previous subtree (including any broken state). */
|
|
39
|
+
epoch: number;
|
|
40
|
+
error: Error | null;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Catches generic errors thrown during render of `children`. Lets
|
|
44
|
+
* `FurinNotFoundError` bubble past so a sibling `<FurinNotFoundBoundary>`
|
|
45
|
+
* can handle it.
|
|
46
|
+
*
|
|
47
|
+
* Must be a class: React error catching (`getDerivedStateFromError`,
|
|
48
|
+
* `componentDidCatch`) has no function-component equivalent.
|
|
49
|
+
*/
|
|
50
|
+
export declare class FurinErrorBoundary extends Component<ErrorBoundaryProps, ErrorBoundaryState> {
|
|
51
|
+
state: ErrorBoundaryState;
|
|
52
|
+
static getDerivedStateFromError(error: Error): Partial<ErrorBoundaryState>;
|
|
53
|
+
componentDidUpdate(prevProps: ErrorBoundaryProps): void;
|
|
54
|
+
reset: () => void;
|
|
55
|
+
render(): ReactNode;
|
|
56
|
+
}
|
|
57
|
+
interface NotFoundBoundaryProps {
|
|
58
|
+
children: ReactNode;
|
|
59
|
+
fallback?: NotFoundComponent;
|
|
60
|
+
resetKey?: string | number;
|
|
61
|
+
}
|
|
62
|
+
interface NotFoundBoundaryState {
|
|
63
|
+
epoch: number;
|
|
64
|
+
error: Error | null;
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Catches `FurinNotFoundError` (thrown by `notFound()`) and renders the
|
|
68
|
+
* nearest not-found UI. Generic errors are re-thrown from render() so a
|
|
69
|
+
* parent `<FurinErrorBoundary>` can handle them.
|
|
70
|
+
*
|
|
71
|
+
* Must be a class: React error catching has no function-component equivalent.
|
|
72
|
+
*/
|
|
73
|
+
export declare class FurinNotFoundBoundary extends Component<NotFoundBoundaryProps, NotFoundBoundaryState> {
|
|
74
|
+
state: NotFoundBoundaryState;
|
|
75
|
+
static getDerivedStateFromError(error: Error): Partial<NotFoundBoundaryState>;
|
|
76
|
+
componentDidUpdate(prevProps: NotFoundBoundaryProps): void;
|
|
77
|
+
render(): ReactNode;
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Options passed to `wrapSegmentBoundaries` when running on the client.
|
|
81
|
+
* The server path omits them entirely.
|
|
82
|
+
*/
|
|
83
|
+
export interface BoundaryOptions {
|
|
84
|
+
onReset?: () => void;
|
|
85
|
+
resetKey?: string | number;
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Minimal shape of a segment boundary descriptor, accepted by both server-side
|
|
89
|
+
* `SegmentBoundary` and client-side `ClientSegmentBoundary`.
|
|
90
|
+
*/
|
|
91
|
+
export interface SegmentBoundaryLike {
|
|
92
|
+
error?: ErrorComponent;
|
|
93
|
+
notFound?: NotFoundComponent;
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Wraps `inner` with the boundary pair declared at a single segment depth.
|
|
97
|
+
*
|
|
98
|
+
* The ordering is deliberate and MUST be kept identical on server **and**
|
|
99
|
+
* client so that hydration sees the exact same React tree:
|
|
100
|
+
*
|
|
101
|
+
* <FurinErrorBoundary>
|
|
102
|
+
* <FurinNotFoundBoundary>{inner}</FurinNotFoundBoundary>
|
|
103
|
+
* </FurinErrorBoundary>
|
|
104
|
+
*
|
|
105
|
+
* `FurinErrorBoundary` is OUTSIDE because it re-throws `FurinNotFoundError`
|
|
106
|
+
* during render, allowing an ancestor not-found boundary to catch it. Placing
|
|
107
|
+
* the not-found boundary inside would mean the same-depth error boundary
|
|
108
|
+
* catches a `notFound()` throw first, latches onto it, and the re-throw would
|
|
109
|
+
* not find a `NotFoundBoundary` deeper than itself — it needs one higher up.
|
|
110
|
+
*
|
|
111
|
+
* @param inner - React subtree to wrap.
|
|
112
|
+
* @param segment - Boundary descriptor for this depth (may be undefined).
|
|
113
|
+
* @param options - Optional client-side reset options (ignored on server).
|
|
114
|
+
* @returns The wrapped React node.
|
|
115
|
+
*/
|
|
116
|
+
export declare function wrapSegmentBoundaries(inner: ReactNode, segment: SegmentBoundaryLike | undefined, options: BoundaryOptions | undefined): ReactNode;
|
|
117
|
+
export {};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { ErrorComponent } from "../shared/error.ts";
|
|
2
|
+
import type { NotFoundComponent } from "../shared/not-found.ts";
|
|
3
|
+
interface DefaultErrorScreenProps {
|
|
4
|
+
digest: string;
|
|
5
|
+
message: string;
|
|
6
|
+
reset: () => void;
|
|
7
|
+
}
|
|
8
|
+
export declare function DefaultErrorScreen({ message, digest, reset }: DefaultErrorScreenProps): import("react").JSX.Element;
|
|
9
|
+
interface DefaultNotFoundScreenProps {
|
|
10
|
+
message: string | undefined;
|
|
11
|
+
}
|
|
12
|
+
export declare function DefaultNotFoundScreen({ message }: DefaultNotFoundScreenProps): import("react").JSX.Element;
|
|
13
|
+
/** Adapter that turns `DefaultErrorScreen` into an `ErrorComponent` shape. */
|
|
14
|
+
export declare const DefaultErrorFallback: ErrorComponent;
|
|
15
|
+
/** Adapter that turns `DefaultNotFoundScreen` into a `NotFoundComponent` shape. */
|
|
16
|
+
export declare const DefaultNotFoundFallback: NotFoundComponent;
|
|
17
|
+
export {};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type React from "react";
|
|
2
|
+
import { type LinkProps, type RouterContextValue, type RouteTo } from "./router/index.ts";
|
|
3
|
+
export * from "./router/index.ts";
|
|
4
|
+
/**
|
|
5
|
+
* Static fallback used by Link during SSR when there is no RouterProvider.
|
|
6
|
+
* Must not reference `window` — this object is created at module parse time.
|
|
7
|
+
*/
|
|
8
|
+
/** @internal Exported for unit testing only. */
|
|
9
|
+
export declare const SSR_FALLBACK_ROUTER: RouterContextValue;
|
|
10
|
+
/**
|
|
11
|
+
* SSR-aware Link component.
|
|
12
|
+
*
|
|
13
|
+
* - **Server (SSR):** uses `RouterContext.Consumer` (a render-prop, not a hook)
|
|
14
|
+
* to read basePath / currentHref from any enclosing RouterProvider, then
|
|
15
|
+
* falls back to `SSR_FALLBACK_ROUTER` when no provider is present.
|
|
16
|
+
* `Context.Consumer` bypasses `ReactCurrentDispatcher` entirely, so it is
|
|
17
|
+
* safe even when two React instances coexist in the module graph (Bun HMR).
|
|
18
|
+
* - **Client:** delegates to `LinkInteractive` which adds preloading, SPA
|
|
19
|
+
* navigation, active-state tracking and all other interactive features.
|
|
20
|
+
*/
|
|
21
|
+
export declare function Link<To extends RouteTo>(props: LinkProps<To>): React.ReactElement;
|
|
22
|
+
export { fromCrossJSON } from "seroval";
|