@real-router/react 0.27.1 → 0.27.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/dist/cjs/Await-D2oCO8nH.d.ts.map +1 -1
- package/dist/cjs/HttpStatusProvider-DfsVxZba.d.ts.map +1 -1
- package/dist/cjs/{Link-CyDwbrFA.js → Link-D4K4T0Ef.js} +2 -2
- package/dist/cjs/{Link-CyDwbrFA.js.map → Link-D4K4T0Ef.js.map} +1 -1
- package/dist/cjs/RouterErrorBoundary-3UhUelqY.d.ts.map +1 -1
- package/dist/cjs/{RouterProvider-CPsCmrRw.js → RouterProvider-CAaKExt_.js} +2 -2
- package/dist/cjs/RouterProvider-CAaKExt_.js.map +1 -0
- package/dist/cjs/createHttpStatusSink-ChfBL87y.js.map +1 -1
- package/dist/cjs/index.js +1 -1
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/ink.js +1 -1
- package/dist/cjs/ink.js.map +1 -1
- package/dist/cjs/legacy.js +1 -1
- package/dist/cjs/ssr.js.map +1 -1
- package/dist/cjs/useDeferred-2fAqMTwr.d.ts.map +1 -1
- package/dist/cjs/useRoute-D2vAzKWM.js.map +1 -1
- package/dist/cjs/useRouteEnter-CqO9sPPD.d.ts.map +1 -1
- package/dist/cjs/useRouterTransition-D5nwRENd.d.ts.map +1 -1
- package/dist/esm/Await-D2oCO8nH.d.mts.map +1 -1
- package/dist/esm/HttpStatusProvider-DfsVxZba.d.mts.map +1 -1
- package/dist/esm/{Link-uERoM4yk.mjs → Link-PQIMnFd0.mjs} +2 -2
- package/dist/esm/{Link-uERoM4yk.mjs.map → Link-PQIMnFd0.mjs.map} +1 -1
- package/dist/esm/RouterErrorBoundary-3UhUelqY.d.mts.map +1 -1
- package/dist/esm/{RouterProvider-DgHypQTJ.mjs → RouterProvider-DhZoi6au.mjs} +2 -2
- package/dist/esm/RouterProvider-DhZoi6au.mjs.map +1 -0
- package/dist/esm/index.mjs +1 -1
- package/dist/esm/index.mjs.map +1 -1
- package/dist/esm/ink.mjs +1 -1
- package/dist/esm/ink.mjs.map +1 -1
- package/dist/esm/legacy.mjs +1 -1
- package/dist/esm/useDeferred-2fAqMTwr.d.mts.map +1 -1
- package/dist/esm/useRouteEnter-CqO9sPPD.d.mts.map +1 -1
- package/dist/esm/useRouterTransition-PCwA_qj1.d.mts.map +1 -1
- package/package.json +7 -8
- package/dist/cjs/RouterProvider-CPsCmrRw.js.map +0 -1
- package/dist/esm/RouterProvider-DgHypQTJ.mjs.map +0 -1
- package/src/RouterProvider.tsx +0 -148
- package/src/components/Await.tsx +0 -46
- package/src/components/ClientOnly.tsx +0 -25
- package/src/components/HttpStatusCode.tsx +0 -66
- package/src/components/HttpStatusProvider.tsx +0 -26
- package/src/components/InkLink.tsx +0 -134
- package/src/components/InkRouterProvider.tsx +0 -9
- package/src/components/Link.tsx +0 -117
- package/src/components/RouterErrorBoundary.tsx +0 -69
- package/src/components/ServerOnly.tsx +0 -26
- package/src/components/Streamed.tsx +0 -30
- package/src/components/modern/RouteView/RouteView.tsx +0 -69
- package/src/components/modern/RouteView/components.tsx +0 -19
- package/src/components/modern/RouteView/helpers.tsx +0 -233
- package/src/components/modern/RouteView/index.ts +0 -8
- package/src/components/modern/RouteView/types.ts +0 -38
- package/src/constants.ts +0 -10
- package/src/context.ts +0 -14
- package/src/hooks/useDeferred.tsx +0 -34
- package/src/hooks/useIsActiveRoute.tsx +0 -47
- package/src/hooks/useNavigator.tsx +0 -15
- package/src/hooks/useRoute.tsx +0 -32
- package/src/hooks/useRouteEnter.tsx +0 -148
- package/src/hooks/useRouteExit.tsx +0 -159
- package/src/hooks/useRouteNode.tsx +0 -37
- package/src/hooks/useRouteUtils.tsx +0 -35
- package/src/hooks/useRouter.tsx +0 -15
- package/src/hooks/useRouterTransition.tsx +0 -17
- package/src/index.react-server.ts +0 -33
- package/src/index.ts +0 -61
- package/src/ink-types.ts +0 -25
- package/src/ink.ts +0 -30
- package/src/legacy.ssr.ts +0 -35
- package/src/legacy.ts +0 -35
- package/src/ssr.react-server.ts +0 -21
- package/src/ssr.ts +0 -43
- package/src/types.ts +0 -40
- package/src/utils/createHttpStatusSink.ts +0 -27
|
@@ -1,159 +0,0 @@
|
|
|
1
|
-
import { useEffect, useLayoutEffect, useRef } from "react";
|
|
2
|
-
|
|
3
|
-
import { useRouter } from "./useRouter";
|
|
4
|
-
|
|
5
|
-
import type { State } from "@real-router/core";
|
|
6
|
-
|
|
7
|
-
export interface RouteExitContext {
|
|
8
|
-
/** The route being left. */
|
|
9
|
-
route: State;
|
|
10
|
-
/** The route being navigated to. */
|
|
11
|
-
nextRoute: State;
|
|
12
|
-
/**
|
|
13
|
-
* AbortSignal that fires when this navigation is superseded by a later
|
|
14
|
-
* one (rapid clicks). Already filtered: when the handler runs,
|
|
15
|
-
* `signal.aborted` is guaranteed to be `false`. Use
|
|
16
|
-
* `signal.addEventListener("abort", cleanup, { once: true })` for
|
|
17
|
-
* cleanup that must run on cancellation.
|
|
18
|
-
*/
|
|
19
|
-
signal: AbortSignal;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
export interface UseRouteExitOptions {
|
|
23
|
-
/**
|
|
24
|
-
* Skip the handler when `route.name === nextRoute.name`
|
|
25
|
-
* (sort/filter/query-only navigations on the same route). Default:
|
|
26
|
-
* `true`.
|
|
27
|
-
*/
|
|
28
|
-
skipSameRoute?: boolean;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
export type RouteExitHandler = (
|
|
32
|
-
context: RouteExitContext,
|
|
33
|
-
) => void | Promise<void>;
|
|
34
|
-
|
|
35
|
-
/**
|
|
36
|
-
* Subscribe to the router's leave-window with the universal guards baked
|
|
37
|
-
* in. Wraps `router.subscribeLeave` so consumers don't repeat the same
|
|
38
|
-
* boilerplate every time:
|
|
39
|
-
*
|
|
40
|
-
* - **Reentrant abort pre-check**: if `signal.aborted` is already `true`
|
|
41
|
-
* when the handler would run (rapid navigation superseded a slower
|
|
42
|
-
* one), the handler is skipped entirely. `signal.addEventListener(
|
|
43
|
-
* "abort", ...)` does not fire retroactively, so without this guard
|
|
44
|
-
* downstream cleanup would never trigger.
|
|
45
|
-
* - **Same-route skip**: by default, `route.name === nextRoute.name`
|
|
46
|
-
* short-circuits the handler — query-only navigations (sort, filter,
|
|
47
|
-
* pagination) skip the work. Opt out with `skipSameRoute: false`.
|
|
48
|
-
* - **Stable handler reference**: the handler can change identity on
|
|
49
|
-
* every render without causing resubscription — internal ref keeps
|
|
50
|
-
* the latest handler accessible to the long-lived subscription.
|
|
51
|
-
*
|
|
52
|
-
* Returns nothing — the subscription's lifecycle is bound to the
|
|
53
|
-
* component's mount.
|
|
54
|
-
*
|
|
55
|
-
* If the handler returns a Promise, the router blocks on it. If the
|
|
56
|
-
* Promise resolves, navigation proceeds. If it rejects, the router emits
|
|
57
|
-
* `TRANSITION_CANCELLED` (existing core behavior, no change here).
|
|
58
|
-
*
|
|
59
|
-
* @example Animation
|
|
60
|
-
* ```tsx
|
|
61
|
-
* const ref = useRef<HTMLDivElement>(null);
|
|
62
|
-
*
|
|
63
|
-
* useRouteExit(async ({ signal }) => {
|
|
64
|
-
* const el = ref.current;
|
|
65
|
-
* if (!el) return;
|
|
66
|
-
* el.classList.add("fade-out");
|
|
67
|
-
* const cleanup = () => el.classList.remove("fade-out");
|
|
68
|
-
* signal.addEventListener("abort", cleanup, { once: true });
|
|
69
|
-
* try {
|
|
70
|
-
* el.getBoundingClientRect(); // style flush
|
|
71
|
-
* await Promise.allSettled(el.getAnimations().map((a) => a.finished));
|
|
72
|
-
* } finally {
|
|
73
|
-
* cleanup();
|
|
74
|
-
* }
|
|
75
|
-
* });
|
|
76
|
-
* ```
|
|
77
|
-
*
|
|
78
|
-
* @example Auto-save form draft
|
|
79
|
-
* ```tsx
|
|
80
|
-
* useRouteExit(async ({ signal }) => {
|
|
81
|
-
* if (formState.dirty) await api.saveDraft(formState, { signal });
|
|
82
|
-
* });
|
|
83
|
-
* ```
|
|
84
|
-
*
|
|
85
|
-
* @example Cancel inflight requests
|
|
86
|
-
* ```tsx
|
|
87
|
-
* useRouteExit(() => {
|
|
88
|
-
* inflightController.abort();
|
|
89
|
-
* });
|
|
90
|
-
* ```
|
|
91
|
-
*
|
|
92
|
-
* @example Library-coordinated exit (motion / framer-motion)
|
|
93
|
-
* ```tsx
|
|
94
|
-
* const exitResolverRef = useRef<(() => void) | null>(null);
|
|
95
|
-
*
|
|
96
|
-
* useRouteExit(({ signal }) => {
|
|
97
|
-
* return new Promise<void>((resolve) => {
|
|
98
|
-
* exitResolverRef.current = resolve;
|
|
99
|
-
* signal.addEventListener("abort", () => resolve(), { once: true });
|
|
100
|
-
* });
|
|
101
|
-
* });
|
|
102
|
-
*
|
|
103
|
-
* const onExitComplete = () => exitResolverRef.current?.();
|
|
104
|
-
* // pass onExitComplete to <AnimatePresence>
|
|
105
|
-
* ```
|
|
106
|
-
*
|
|
107
|
-
* @example Reading rich transition metadata via `nextRoute.transition`
|
|
108
|
-
* ```tsx
|
|
109
|
-
* useRouteExit(({ route, nextRoute }) => {
|
|
110
|
-
* // nextRoute.transition: TransitionMeta — preview of the upcoming nav
|
|
111
|
-
* if (nextRoute.transition.segments.deactivated.includes("products")) {
|
|
112
|
-
* // leaving the products subtree entirely — flush product-related caches
|
|
113
|
-
* productCache.clear();
|
|
114
|
-
* }
|
|
115
|
-
* if (nextRoute.transition.redirected) {
|
|
116
|
-
* // skip animation when navigation arrived via redirect
|
|
117
|
-
* return;
|
|
118
|
-
* }
|
|
119
|
-
* });
|
|
120
|
-
* ```
|
|
121
|
-
*/
|
|
122
|
-
export function useRouteExit(
|
|
123
|
-
handler: RouteExitHandler,
|
|
124
|
-
options?: UseRouteExitOptions,
|
|
125
|
-
): void {
|
|
126
|
-
const router = useRouter();
|
|
127
|
-
const handlerRef = useRef(handler);
|
|
128
|
-
const skipSameRoute = options?.skipSameRoute ?? true;
|
|
129
|
-
|
|
130
|
-
// Keep the latest handler accessible to the subscription without
|
|
131
|
-
// resubscribing on every render — the subscription registers the
|
|
132
|
-
// wrapper once and dispatches to whatever ref points to.
|
|
133
|
-
// useLayoutEffect (synchronous, post-render, pre-paint) updates the
|
|
134
|
-
// ref before the browser can dispatch any router events that could
|
|
135
|
-
// observe a stale closure.
|
|
136
|
-
useLayoutEffect(() => {
|
|
137
|
-
handlerRef.current = handler;
|
|
138
|
-
});
|
|
139
|
-
|
|
140
|
-
useEffect(() => {
|
|
141
|
-
return router.subscribeLeave(({ route, nextRoute, signal }) => {
|
|
142
|
-
if (skipSameRoute && route.name === nextRoute.name) {
|
|
143
|
-
return;
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
// Reentrant abort: signal is already aborted when listener fires
|
|
147
|
-
// (e.g. a newer navigate superseded this one before subscribeLeave
|
|
148
|
-
// even ran). addEventListener("abort", ...) does not fire
|
|
149
|
-
// retroactively, so we skip the handler entirely — any cleanup the
|
|
150
|
-
// handler would have wired via abort listener must not run because
|
|
151
|
-
// the corresponding `add` work never happened.
|
|
152
|
-
if (signal.aborted) {
|
|
153
|
-
return;
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
return handlerRef.current({ route, nextRoute, signal });
|
|
157
|
-
});
|
|
158
|
-
}, [router, skipSameRoute]);
|
|
159
|
-
}
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import { getNavigator } from "@real-router/core";
|
|
2
|
-
import { createRouteNodeSource } from "@real-router/sources";
|
|
3
|
-
import { useMemo, useSyncExternalStore } from "react";
|
|
4
|
-
|
|
5
|
-
import { useRouter } from "./useRouter";
|
|
6
|
-
|
|
7
|
-
import type { RouteContext } from "../types";
|
|
8
|
-
|
|
9
|
-
export function useRouteNode(nodeName: string): RouteContext {
|
|
10
|
-
const router = useRouter();
|
|
11
|
-
|
|
12
|
-
const store = useMemo(
|
|
13
|
-
() => createRouteNodeSource(router, nodeName),
|
|
14
|
-
[router, nodeName],
|
|
15
|
-
);
|
|
16
|
-
|
|
17
|
-
// Use snapshot reference directly. createRouteNodeSource via stabilizeState
|
|
18
|
-
// returns the SAME snapshot when the node-relevant state did not change,
|
|
19
|
-
// so memoization on `[navigator, snapshot]` preserves identity for consumers.
|
|
20
|
-
const snapshot = useSyncExternalStore(
|
|
21
|
-
store.subscribe,
|
|
22
|
-
store.getSnapshot,
|
|
23
|
-
store.getSnapshot, // SSR: router returns same state on server and client
|
|
24
|
-
);
|
|
25
|
-
|
|
26
|
-
// getNavigator is WeakMap-cached in core; additional useMemo is redundant.
|
|
27
|
-
const navigator = getNavigator(router);
|
|
28
|
-
|
|
29
|
-
return useMemo(
|
|
30
|
-
(): RouteContext => ({
|
|
31
|
-
navigator,
|
|
32
|
-
route: snapshot.route,
|
|
33
|
-
previousRoute: snapshot.previousRoute,
|
|
34
|
-
}),
|
|
35
|
-
[navigator, snapshot],
|
|
36
|
-
);
|
|
37
|
-
}
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import { getPluginApi } from "@real-router/core/api";
|
|
2
|
-
import { getRouteUtils } from "@real-router/route-utils";
|
|
3
|
-
|
|
4
|
-
import { useRouter } from "./useRouter";
|
|
5
|
-
|
|
6
|
-
import type { RouteUtils } from "@real-router/route-utils";
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* Returns a pre-computed {@link RouteUtils} instance for the current router.
|
|
10
|
-
*
|
|
11
|
-
* `getRouteUtils` is WeakMap-cached per `RouteTreeNode` inside
|
|
12
|
-
* `@real-router/route-utils`, so the same router always returns the same
|
|
13
|
-
* `RouteUtils` instance across renders — no local cache needed in the adapter.
|
|
14
|
-
*
|
|
15
|
-
* @returns RouteUtils instance with pre-computed chains and siblings
|
|
16
|
-
*
|
|
17
|
-
* @example
|
|
18
|
-
* ```tsx
|
|
19
|
-
* const utils = useRouteUtils();
|
|
20
|
-
*
|
|
21
|
-
* utils.getChain("users.profile");
|
|
22
|
-
* // → ["users", "users.profile"]
|
|
23
|
-
*
|
|
24
|
-
* utils.getSiblings("users");
|
|
25
|
-
* // → ["admin"]
|
|
26
|
-
*
|
|
27
|
-
* utils.isDescendantOf("users.profile", "users");
|
|
28
|
-
* // → true
|
|
29
|
-
* ```
|
|
30
|
-
*/
|
|
31
|
-
export const useRouteUtils = (): RouteUtils => {
|
|
32
|
-
const router = useRouter();
|
|
33
|
-
|
|
34
|
-
return getRouteUtils(getPluginApi(router).getTree());
|
|
35
|
-
};
|
package/src/hooks/useRouter.tsx
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { useContext } from "react";
|
|
2
|
-
|
|
3
|
-
import { RouterContext } from "../context";
|
|
4
|
-
|
|
5
|
-
import type { Router } from "@real-router/core";
|
|
6
|
-
|
|
7
|
-
export const useRouter = (): Router => {
|
|
8
|
-
const router = useContext(RouterContext);
|
|
9
|
-
|
|
10
|
-
if (!router) {
|
|
11
|
-
throw new Error("useRouter must be used within a RouterProvider");
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
return router;
|
|
15
|
-
};
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { getTransitionSource } from "@real-router/sources";
|
|
2
|
-
import { useSyncExternalStore } from "react";
|
|
3
|
-
|
|
4
|
-
import { useRouter } from "./useRouter";
|
|
5
|
-
|
|
6
|
-
import type { RouterTransitionSnapshot } from "@real-router/sources";
|
|
7
|
-
|
|
8
|
-
export function useRouterTransition(): RouterTransitionSnapshot {
|
|
9
|
-
const router = useRouter();
|
|
10
|
-
const store = getTransitionSource(router);
|
|
11
|
-
|
|
12
|
-
return useSyncExternalStore(
|
|
13
|
-
store.subscribe,
|
|
14
|
-
store.getSnapshot,
|
|
15
|
-
store.getSnapshot,
|
|
16
|
-
);
|
|
17
|
-
}
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
// React Server entry — type-only re-exports under `react-server` condition (RSC bundlers). See CLAUDE.md.
|
|
2
|
-
//
|
|
3
|
-
// SSR-feature prop types (`AwaitProps`, `StreamedProps`, `ClientOnlyProps`,
|
|
4
|
-
// `ServerOnlyProps`) live in the `/ssr.react-server` entry — Server
|
|
5
|
-
// Components that need them import from `@real-router/react/ssr` (resolves
|
|
6
|
-
// to types only under the `react-server` condition).
|
|
7
|
-
|
|
8
|
-
export type { LinkProps } from "./types";
|
|
9
|
-
|
|
10
|
-
export type {
|
|
11
|
-
RouteExitContext,
|
|
12
|
-
RouteExitHandler,
|
|
13
|
-
UseRouteExitOptions,
|
|
14
|
-
} from "./hooks/useRouteExit";
|
|
15
|
-
|
|
16
|
-
export type {
|
|
17
|
-
RouteEnterContext,
|
|
18
|
-
RouteEnterHandler,
|
|
19
|
-
UseRouteEnterOptions,
|
|
20
|
-
} from "./hooks/useRouteEnter";
|
|
21
|
-
|
|
22
|
-
export type {
|
|
23
|
-
RouteViewProps,
|
|
24
|
-
RouteViewMatchProps,
|
|
25
|
-
RouteViewSelfProps,
|
|
26
|
-
RouteViewNotFoundProps,
|
|
27
|
-
} from "./components/modern/RouteView";
|
|
28
|
-
|
|
29
|
-
export type { RouterErrorBoundaryProps } from "./components/RouterErrorBoundary";
|
|
30
|
-
|
|
31
|
-
export type { Navigator } from "@real-router/core";
|
|
32
|
-
|
|
33
|
-
export type { RouterTransitionSnapshot } from "@real-router/sources";
|
package/src/index.ts
DELETED
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
// Main entry point — React 19.2+
|
|
2
|
-
//
|
|
3
|
-
// Client-side hooks + components. SSR-aware components and hooks
|
|
4
|
-
// (`<ClientOnly>`, `<ServerOnly>`, `<Await>`, `<Streamed>`, `useDeferred`)
|
|
5
|
-
// have moved to the `/ssr` subpath — import them from
|
|
6
|
-
// `@real-router/react/ssr` to opt into the SSR-feature surface.
|
|
7
|
-
|
|
8
|
-
// Components
|
|
9
|
-
export { RouteView } from "./components/modern/RouteView";
|
|
10
|
-
|
|
11
|
-
export { Link } from "./components/Link";
|
|
12
|
-
|
|
13
|
-
export { RouterErrorBoundary } from "./components/RouterErrorBoundary";
|
|
14
|
-
|
|
15
|
-
// Hooks
|
|
16
|
-
export { useRouter } from "./hooks/useRouter";
|
|
17
|
-
|
|
18
|
-
export { useNavigator } from "./hooks/useNavigator";
|
|
19
|
-
|
|
20
|
-
export { useRouteUtils } from "./hooks/useRouteUtils";
|
|
21
|
-
|
|
22
|
-
export { useRoute } from "./hooks/useRoute";
|
|
23
|
-
|
|
24
|
-
export { useRouteNode } from "./hooks/useRouteNode";
|
|
25
|
-
|
|
26
|
-
export { useRouterTransition } from "./hooks/useRouterTransition";
|
|
27
|
-
|
|
28
|
-
export { useRouteExit } from "./hooks/useRouteExit";
|
|
29
|
-
|
|
30
|
-
export { useRouteEnter } from "./hooks/useRouteEnter";
|
|
31
|
-
|
|
32
|
-
// Context
|
|
33
|
-
export { RouterProvider } from "./RouterProvider";
|
|
34
|
-
|
|
35
|
-
// Types
|
|
36
|
-
export type { LinkProps } from "./types";
|
|
37
|
-
|
|
38
|
-
export type {
|
|
39
|
-
RouteExitContext,
|
|
40
|
-
RouteExitHandler,
|
|
41
|
-
UseRouteExitOptions,
|
|
42
|
-
} from "./hooks/useRouteExit";
|
|
43
|
-
|
|
44
|
-
export type {
|
|
45
|
-
RouteEnterContext,
|
|
46
|
-
RouteEnterHandler,
|
|
47
|
-
UseRouteEnterOptions,
|
|
48
|
-
} from "./hooks/useRouteEnter";
|
|
49
|
-
|
|
50
|
-
export type {
|
|
51
|
-
RouteViewProps,
|
|
52
|
-
RouteViewMatchProps,
|
|
53
|
-
RouteViewSelfProps,
|
|
54
|
-
RouteViewNotFoundProps,
|
|
55
|
-
} from "./components/modern/RouteView";
|
|
56
|
-
|
|
57
|
-
export type { RouterErrorBoundaryProps } from "./components/RouterErrorBoundary";
|
|
58
|
-
|
|
59
|
-
export type { Navigator } from "@real-router/core";
|
|
60
|
-
|
|
61
|
-
export type { RouterTransitionSnapshot } from "@real-router/sources";
|
package/src/ink-types.ts
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import type { NavigationOptions, Params, Router } from "@real-router/core";
|
|
2
|
-
import type { ReactNode } from "react";
|
|
3
|
-
|
|
4
|
-
export interface InkLinkProps<P extends Params = Params> {
|
|
5
|
-
routeName: string;
|
|
6
|
-
routeParams?: P;
|
|
7
|
-
routeOptions?: NavigationOptions;
|
|
8
|
-
activeStrict?: boolean;
|
|
9
|
-
ignoreQueryParams?: boolean;
|
|
10
|
-
children?: ReactNode;
|
|
11
|
-
color?: string;
|
|
12
|
-
activeColor?: string;
|
|
13
|
-
focusColor?: string;
|
|
14
|
-
inverse?: boolean;
|
|
15
|
-
activeInverse?: boolean;
|
|
16
|
-
focusInverse?: boolean;
|
|
17
|
-
id?: string;
|
|
18
|
-
autoFocus?: boolean;
|
|
19
|
-
onSelect?: () => void;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
export interface InkRouterProviderProps {
|
|
23
|
-
router: Router;
|
|
24
|
-
children?: ReactNode;
|
|
25
|
-
}
|
package/src/ink.ts
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
// Ink entry point — React 19.2+ & Ink 7+
|
|
2
|
-
|
|
3
|
-
// Components
|
|
4
|
-
export { InkLink } from "./components/InkLink";
|
|
5
|
-
|
|
6
|
-
export { InkRouterProvider } from "./components/InkRouterProvider";
|
|
7
|
-
|
|
8
|
-
export { RouterErrorBoundary } from "./components/RouterErrorBoundary";
|
|
9
|
-
|
|
10
|
-
// Hooks
|
|
11
|
-
export { useRouteNode } from "./hooks/useRouteNode";
|
|
12
|
-
|
|
13
|
-
export { useRoute } from "./hooks/useRoute";
|
|
14
|
-
|
|
15
|
-
export { useNavigator } from "./hooks/useNavigator";
|
|
16
|
-
|
|
17
|
-
export { useRouter } from "./hooks/useRouter";
|
|
18
|
-
|
|
19
|
-
export { useRouteUtils } from "./hooks/useRouteUtils";
|
|
20
|
-
|
|
21
|
-
export { useRouterTransition } from "./hooks/useRouterTransition";
|
|
22
|
-
|
|
23
|
-
// Types
|
|
24
|
-
export type { InkLinkProps, InkRouterProviderProps } from "./ink-types";
|
|
25
|
-
|
|
26
|
-
export type { RouterErrorBoundaryProps } from "./components/RouterErrorBoundary";
|
|
27
|
-
|
|
28
|
-
export type { Navigator } from "@real-router/core";
|
|
29
|
-
|
|
30
|
-
export type { RouterTransitionSnapshot } from "@real-router/sources";
|
package/src/legacy.ssr.ts
DELETED
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
// SSR-feature entry for the legacy (React 18+) entry point.
|
|
2
|
-
//
|
|
3
|
-
// `<Await>` is excluded — it depends on React 19's `use(promise)` which is
|
|
4
|
-
// not available in React 18. React 18 consumers can compose the same
|
|
5
|
-
// pattern manually with `<Suspense>` + a Suspense-aware data library.
|
|
6
|
-
|
|
7
|
-
// Components
|
|
8
|
-
export { ClientOnly } from "./components/ClientOnly";
|
|
9
|
-
|
|
10
|
-
export { ServerOnly } from "./components/ServerOnly";
|
|
11
|
-
|
|
12
|
-
export { Streamed } from "./components/Streamed";
|
|
13
|
-
|
|
14
|
-
export { HttpStatusCode } from "./components/HttpStatusCode";
|
|
15
|
-
|
|
16
|
-
export { HttpStatusProvider } from "./components/HttpStatusProvider";
|
|
17
|
-
|
|
18
|
-
// Hooks
|
|
19
|
-
export { useDeferred } from "./hooks/useDeferred";
|
|
20
|
-
|
|
21
|
-
// Utilities
|
|
22
|
-
export { createHttpStatusSink } from "./utils/createHttpStatusSink";
|
|
23
|
-
|
|
24
|
-
// Types
|
|
25
|
-
export type { ClientOnlyProps } from "./components/ClientOnly";
|
|
26
|
-
|
|
27
|
-
export type { ServerOnlyProps } from "./components/ServerOnly";
|
|
28
|
-
|
|
29
|
-
export type { StreamedProps } from "./components/Streamed";
|
|
30
|
-
|
|
31
|
-
export type { HttpStatusCodeProps } from "./components/HttpStatusCode";
|
|
32
|
-
|
|
33
|
-
export type { HttpStatusProviderProps } from "./components/HttpStatusProvider";
|
|
34
|
-
|
|
35
|
-
export type { HttpStatusSink } from "./utils/createHttpStatusSink";
|
package/src/legacy.ts
DELETED
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
// Legacy entry point — React 18+
|
|
2
|
-
//
|
|
3
|
-
// SSR-aware components/hooks live at `@real-router/react/legacy/ssr`
|
|
4
|
-
// (subset of the React 19+ `/ssr` surface — `<Await>` is excluded since
|
|
5
|
-
// it depends on `use(promise)`).
|
|
6
|
-
|
|
7
|
-
// Components
|
|
8
|
-
export { Link } from "./components/Link";
|
|
9
|
-
|
|
10
|
-
export { RouterErrorBoundary } from "./components/RouterErrorBoundary";
|
|
11
|
-
|
|
12
|
-
// Hooks
|
|
13
|
-
export { useRouteNode } from "./hooks/useRouteNode";
|
|
14
|
-
|
|
15
|
-
export { useRoute } from "./hooks/useRoute";
|
|
16
|
-
|
|
17
|
-
export { useNavigator } from "./hooks/useNavigator";
|
|
18
|
-
|
|
19
|
-
export { useRouter } from "./hooks/useRouter";
|
|
20
|
-
|
|
21
|
-
export { useRouteUtils } from "./hooks/useRouteUtils";
|
|
22
|
-
|
|
23
|
-
export { useRouterTransition } from "./hooks/useRouterTransition";
|
|
24
|
-
|
|
25
|
-
// Context
|
|
26
|
-
export { RouterProvider } from "./RouterProvider";
|
|
27
|
-
|
|
28
|
-
// Types
|
|
29
|
-
export type { LinkProps } from "./types";
|
|
30
|
-
|
|
31
|
-
export type { RouterErrorBoundaryProps } from "./components/RouterErrorBoundary";
|
|
32
|
-
|
|
33
|
-
export type { Navigator } from "@real-router/core";
|
|
34
|
-
|
|
35
|
-
export type { RouterTransitionSnapshot } from "@real-router/sources";
|
package/src/ssr.react-server.ts
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
// SSR-feature entry — type-only re-exports under `react-server` condition.
|
|
2
|
-
//
|
|
3
|
-
// Server Components that consume `<ClientOnly>`/`<ServerOnly>`/`<Await>`/
|
|
4
|
-
// `<Streamed>` props (e.g. for typing wrapper components rendered server-side)
|
|
5
|
-
// import the prop types from `@real-router/react/ssr`. Under the
|
|
6
|
-
// `react-server` condition this entry resolves to types only — no client
|
|
7
|
-
// runtime is pulled into the Server Component bundle.
|
|
8
|
-
|
|
9
|
-
export type { ClientOnlyProps } from "./components/ClientOnly";
|
|
10
|
-
|
|
11
|
-
export type { ServerOnlyProps } from "./components/ServerOnly";
|
|
12
|
-
|
|
13
|
-
export type { AwaitProps } from "./components/Await";
|
|
14
|
-
|
|
15
|
-
export type { StreamedProps } from "./components/Streamed";
|
|
16
|
-
|
|
17
|
-
export type { HttpStatusCodeProps } from "./components/HttpStatusCode";
|
|
18
|
-
|
|
19
|
-
export type { HttpStatusProviderProps } from "./components/HttpStatusProvider";
|
|
20
|
-
|
|
21
|
-
export type { HttpStatusSink } from "./utils/createHttpStatusSink";
|
package/src/ssr.ts
DELETED
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
// SSR-feature entry — React 19.2+
|
|
2
|
-
//
|
|
3
|
-
// Server-side and SSR-aware client components/hooks. Importing from this
|
|
4
|
-
// subpath instead of the main entry signals "this code path is part of
|
|
5
|
-
// the SSR pipeline" and makes server-only types stay out of the client
|
|
6
|
-
// TypeScript context for app code that doesn't touch SSR.
|
|
7
|
-
//
|
|
8
|
-
// Trigger for the split: ≥3 SSR-feature exports (#604 + #610 = 5 exports).
|
|
9
|
-
// See `.claude/SSR_FEATURE_GAPS_RU.md` §8 for the architectural rationale.
|
|
10
|
-
|
|
11
|
-
// Components
|
|
12
|
-
export { ClientOnly } from "./components/ClientOnly";
|
|
13
|
-
|
|
14
|
-
export { ServerOnly } from "./components/ServerOnly";
|
|
15
|
-
|
|
16
|
-
export { Await } from "./components/Await";
|
|
17
|
-
|
|
18
|
-
export { Streamed } from "./components/Streamed";
|
|
19
|
-
|
|
20
|
-
export { HttpStatusCode } from "./components/HttpStatusCode";
|
|
21
|
-
|
|
22
|
-
export { HttpStatusProvider } from "./components/HttpStatusProvider";
|
|
23
|
-
|
|
24
|
-
// Hooks
|
|
25
|
-
export { useDeferred } from "./hooks/useDeferred";
|
|
26
|
-
|
|
27
|
-
// Utilities
|
|
28
|
-
export { createHttpStatusSink } from "./utils/createHttpStatusSink";
|
|
29
|
-
|
|
30
|
-
// Types
|
|
31
|
-
export type { ClientOnlyProps } from "./components/ClientOnly";
|
|
32
|
-
|
|
33
|
-
export type { ServerOnlyProps } from "./components/ServerOnly";
|
|
34
|
-
|
|
35
|
-
export type { AwaitProps } from "./components/Await";
|
|
36
|
-
|
|
37
|
-
export type { StreamedProps } from "./components/Streamed";
|
|
38
|
-
|
|
39
|
-
export type { HttpStatusCodeProps } from "./components/HttpStatusCode";
|
|
40
|
-
|
|
41
|
-
export type { HttpStatusProviderProps } from "./components/HttpStatusProvider";
|
|
42
|
-
|
|
43
|
-
export type { HttpStatusSink } from "./utils/createHttpStatusSink";
|
package/src/types.ts
DELETED
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
NavigationOptions,
|
|
3
|
-
Params,
|
|
4
|
-
Navigator,
|
|
5
|
-
State,
|
|
6
|
-
} from "@real-router/core";
|
|
7
|
-
import type { HTMLAttributes, MouseEventHandler } from "react";
|
|
8
|
-
|
|
9
|
-
export interface RouteState<P extends Params = Params> {
|
|
10
|
-
route: State<P> | undefined;
|
|
11
|
-
previousRoute?: State | undefined;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
export type RouteContext<P extends Params = Params> = {
|
|
15
|
-
navigator: Navigator;
|
|
16
|
-
} & RouteState<P>;
|
|
17
|
-
|
|
18
|
-
export interface LinkProps<
|
|
19
|
-
P extends Params = Params,
|
|
20
|
-
> extends HTMLAttributes<HTMLAnchorElement> {
|
|
21
|
-
routeName: string;
|
|
22
|
-
routeParams?: P;
|
|
23
|
-
routeOptions?: NavigationOptions;
|
|
24
|
-
activeClassName?: string;
|
|
25
|
-
activeStrict?: boolean;
|
|
26
|
-
ignoreQueryParams?: boolean;
|
|
27
|
-
/**
|
|
28
|
-
* URL fragment (decoded form, no leading "#") (#532).
|
|
29
|
-
* - omitted/`undefined` → preserve current fragment on same-route navigation
|
|
30
|
-
* - `""` → clear fragment
|
|
31
|
-
* - non-empty → set fragment
|
|
32
|
-
*
|
|
33
|
-
* Requires a URL plugin (browser-plugin or navigation-plugin) for full
|
|
34
|
-
* round-trip; hash-plugin ignores the prop with a one-time dev warning.
|
|
35
|
-
*/
|
|
36
|
-
hash?: string;
|
|
37
|
-
target?: string;
|
|
38
|
-
onClick?: MouseEventHandler<HTMLAnchorElement>;
|
|
39
|
-
onMouseOver?: MouseEventHandler<HTMLAnchorElement>;
|
|
40
|
-
}
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Render-scoped HTTP status sink. Created per request on the server, passed to
|
|
3
|
-
* `<HttpStatusProvider sink={...}>`, and read after `renderToString` /
|
|
4
|
-
* `renderToReadableStream` to apply the value to the HTTP response.
|
|
5
|
-
*
|
|
6
|
-
* Last write wins: if the rendered tree mounts more than one
|
|
7
|
-
* `<HttpStatusCode />`, the value reflects the last component that ran during
|
|
8
|
-
* the render pass.
|
|
9
|
-
*
|
|
10
|
-
* No-op on the client — `<HttpStatusCode />` reads the optional context and
|
|
11
|
-
* skips the write when no provider is mounted, so the same component tree can
|
|
12
|
-
* be hydrated without changing behaviour.
|
|
13
|
-
*
|
|
14
|
-
* Constraints:
|
|
15
|
-
* - **Per-request only.** Don't share a sink across requests; the rendered
|
|
16
|
-
* tree mutates `code` in place. Module-level singletons leak status
|
|
17
|
-
* between concurrent requests.
|
|
18
|
-
* - **Don't `Object.freeze` the sink.** The component writes to `.code`;
|
|
19
|
-
* freezing makes the assignment throw under ESM strict mode.
|
|
20
|
-
*/
|
|
21
|
-
export interface HttpStatusSink {
|
|
22
|
-
code: number | undefined;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
export function createHttpStatusSink(): HttpStatusSink {
|
|
26
|
-
return { code: undefined };
|
|
27
|
-
}
|