@rangojs/router 0.0.0-experimental.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.
Files changed (155) hide show
  1. package/CLAUDE.md +7 -0
  2. package/README.md +19 -0
  3. package/dist/vite/index.js +1298 -0
  4. package/package.json +140 -0
  5. package/skills/caching/SKILL.md +319 -0
  6. package/skills/document-cache/SKILL.md +152 -0
  7. package/skills/hooks/SKILL.md +359 -0
  8. package/skills/intercept/SKILL.md +292 -0
  9. package/skills/layout/SKILL.md +216 -0
  10. package/skills/loader/SKILL.md +365 -0
  11. package/skills/middleware/SKILL.md +442 -0
  12. package/skills/parallel/SKILL.md +255 -0
  13. package/skills/route/SKILL.md +141 -0
  14. package/skills/router-setup/SKILL.md +403 -0
  15. package/skills/theme/SKILL.md +54 -0
  16. package/skills/typesafety/SKILL.md +352 -0
  17. package/src/__mocks__/version.ts +6 -0
  18. package/src/__tests__/component-utils.test.ts +76 -0
  19. package/src/__tests__/route-definition.test.ts +63 -0
  20. package/src/__tests__/urls.test.tsx +436 -0
  21. package/src/browser/event-controller.ts +876 -0
  22. package/src/browser/index.ts +18 -0
  23. package/src/browser/link-interceptor.ts +121 -0
  24. package/src/browser/lru-cache.ts +69 -0
  25. package/src/browser/merge-segment-loaders.ts +126 -0
  26. package/src/browser/navigation-bridge.ts +893 -0
  27. package/src/browser/navigation-client.ts +162 -0
  28. package/src/browser/navigation-store.ts +823 -0
  29. package/src/browser/partial-update.ts +559 -0
  30. package/src/browser/react/Link.tsx +248 -0
  31. package/src/browser/react/NavigationProvider.tsx +275 -0
  32. package/src/browser/react/ScrollRestoration.tsx +94 -0
  33. package/src/browser/react/context.ts +53 -0
  34. package/src/browser/react/index.ts +52 -0
  35. package/src/browser/react/location-state-shared.ts +120 -0
  36. package/src/browser/react/location-state.ts +62 -0
  37. package/src/browser/react/use-action.ts +240 -0
  38. package/src/browser/react/use-client-cache.ts +56 -0
  39. package/src/browser/react/use-handle.ts +178 -0
  40. package/src/browser/react/use-href.tsx +208 -0
  41. package/src/browser/react/use-link-status.ts +134 -0
  42. package/src/browser/react/use-navigation.ts +150 -0
  43. package/src/browser/react/use-segments.ts +188 -0
  44. package/src/browser/request-controller.ts +164 -0
  45. package/src/browser/rsc-router.tsx +353 -0
  46. package/src/browser/scroll-restoration.ts +324 -0
  47. package/src/browser/server-action-bridge.ts +747 -0
  48. package/src/browser/shallow.ts +35 -0
  49. package/src/browser/types.ts +464 -0
  50. package/src/cache/__tests__/document-cache.test.ts +522 -0
  51. package/src/cache/__tests__/memory-segment-store.test.ts +487 -0
  52. package/src/cache/__tests__/memory-store.test.ts +484 -0
  53. package/src/cache/cache-scope.ts +565 -0
  54. package/src/cache/cf/__tests__/cf-cache-store.test.ts +428 -0
  55. package/src/cache/cf/cf-cache-store.ts +428 -0
  56. package/src/cache/cf/index.ts +19 -0
  57. package/src/cache/document-cache.ts +340 -0
  58. package/src/cache/index.ts +58 -0
  59. package/src/cache/memory-segment-store.ts +150 -0
  60. package/src/cache/memory-store.ts +253 -0
  61. package/src/cache/types.ts +387 -0
  62. package/src/client.rsc.tsx +88 -0
  63. package/src/client.tsx +621 -0
  64. package/src/component-utils.ts +76 -0
  65. package/src/components/DefaultDocument.tsx +23 -0
  66. package/src/default-error-boundary.tsx +88 -0
  67. package/src/deps/browser.ts +8 -0
  68. package/src/deps/html-stream-client.ts +2 -0
  69. package/src/deps/html-stream-server.ts +2 -0
  70. package/src/deps/rsc.ts +10 -0
  71. package/src/deps/ssr.ts +2 -0
  72. package/src/errors.ts +259 -0
  73. package/src/handle.ts +120 -0
  74. package/src/handles/MetaTags.tsx +193 -0
  75. package/src/handles/index.ts +6 -0
  76. package/src/handles/meta.ts +247 -0
  77. package/src/href-client.ts +128 -0
  78. package/src/href-context.ts +33 -0
  79. package/src/href.ts +177 -0
  80. package/src/index.rsc.ts +79 -0
  81. package/src/index.ts +87 -0
  82. package/src/loader.rsc.ts +204 -0
  83. package/src/loader.ts +47 -0
  84. package/src/network-error-thrower.tsx +21 -0
  85. package/src/outlet-context.ts +15 -0
  86. package/src/root-error-boundary.tsx +277 -0
  87. package/src/route-content-wrapper.tsx +198 -0
  88. package/src/route-definition.ts +1371 -0
  89. package/src/route-map-builder.ts +146 -0
  90. package/src/route-types.ts +198 -0
  91. package/src/route-utils.ts +89 -0
  92. package/src/router/__tests__/match-context.test.ts +104 -0
  93. package/src/router/__tests__/match-pipelines.test.ts +537 -0
  94. package/src/router/__tests__/match-result.test.ts +566 -0
  95. package/src/router/__tests__/on-error.test.ts +935 -0
  96. package/src/router/__tests__/pattern-matching.test.ts +577 -0
  97. package/src/router/error-handling.ts +287 -0
  98. package/src/router/handler-context.ts +158 -0
  99. package/src/router/loader-resolution.ts +326 -0
  100. package/src/router/manifest.ts +138 -0
  101. package/src/router/match-context.ts +264 -0
  102. package/src/router/match-middleware/background-revalidation.ts +236 -0
  103. package/src/router/match-middleware/cache-lookup.ts +261 -0
  104. package/src/router/match-middleware/cache-store.ts +266 -0
  105. package/src/router/match-middleware/index.ts +81 -0
  106. package/src/router/match-middleware/intercept-resolution.ts +268 -0
  107. package/src/router/match-middleware/segment-resolution.ts +174 -0
  108. package/src/router/match-pipelines.ts +214 -0
  109. package/src/router/match-result.ts +214 -0
  110. package/src/router/metrics.ts +62 -0
  111. package/src/router/middleware.test.ts +1355 -0
  112. package/src/router/middleware.ts +748 -0
  113. package/src/router/pattern-matching.ts +272 -0
  114. package/src/router/revalidation.ts +190 -0
  115. package/src/router/router-context.ts +299 -0
  116. package/src/router/types.ts +96 -0
  117. package/src/router.ts +3876 -0
  118. package/src/rsc/__tests__/helpers.test.ts +175 -0
  119. package/src/rsc/handler.ts +1060 -0
  120. package/src/rsc/helpers.ts +64 -0
  121. package/src/rsc/index.ts +56 -0
  122. package/src/rsc/nonce.ts +18 -0
  123. package/src/rsc/types.ts +237 -0
  124. package/src/segment-system.tsx +456 -0
  125. package/src/server/__tests__/request-context.test.ts +171 -0
  126. package/src/server/context.ts +417 -0
  127. package/src/server/handle-store.ts +230 -0
  128. package/src/server/loader-registry.ts +174 -0
  129. package/src/server/request-context.ts +554 -0
  130. package/src/server/root-layout.tsx +10 -0
  131. package/src/server/tsconfig.json +14 -0
  132. package/src/server.ts +146 -0
  133. package/src/ssr/__tests__/ssr-handler.test.tsx +188 -0
  134. package/src/ssr/index.tsx +234 -0
  135. package/src/theme/ThemeProvider.tsx +291 -0
  136. package/src/theme/ThemeScript.tsx +61 -0
  137. package/src/theme/__tests__/theme.test.ts +120 -0
  138. package/src/theme/constants.ts +55 -0
  139. package/src/theme/index.ts +58 -0
  140. package/src/theme/theme-context.ts +70 -0
  141. package/src/theme/theme-script.ts +152 -0
  142. package/src/theme/types.ts +182 -0
  143. package/src/theme/use-theme.ts +44 -0
  144. package/src/types.ts +1561 -0
  145. package/src/urls.ts +726 -0
  146. package/src/use-loader.tsx +346 -0
  147. package/src/vite/__tests__/expose-loader-id.test.ts +117 -0
  148. package/src/vite/expose-action-id.ts +344 -0
  149. package/src/vite/expose-handle-id.ts +209 -0
  150. package/src/vite/expose-loader-id.ts +357 -0
  151. package/src/vite/expose-location-state-id.ts +177 -0
  152. package/src/vite/index.ts +787 -0
  153. package/src/vite/package-resolution.ts +125 -0
  154. package/src/vite/version.d.ts +12 -0
  155. package/src/vite/virtual-entries.ts +109 -0
@@ -0,0 +1,35 @@
1
+ /**
2
+ * Shallow comparison utility for selector optimization
3
+ *
4
+ * Used by useNavigation hook to prevent unnecessary re-renders
5
+ * when the selected value hasn't changed.
6
+ *
7
+ * @param a - First value
8
+ * @param b - Second value
9
+ * @returns true if values are shallowly equal
10
+ */
11
+ export function shallow<T>(a: T, b: T): boolean {
12
+ // Same reference or primitive equality
13
+ if (Object.is(a, b)) return true;
14
+
15
+ // Different types or non-objects
16
+ if (typeof a !== "object" || typeof b !== "object") return false;
17
+
18
+ // Null checks
19
+ if (a === null || b === null) return false;
20
+
21
+ // Compare object keys
22
+ const keysA = Object.keys(a);
23
+ const keysB = Object.keys(b);
24
+
25
+ if (keysA.length !== keysB.length) return false;
26
+
27
+ // Check each key's value with Object.is
28
+ for (const key of keysA) {
29
+ if (!Object.is((a as Record<string, unknown>)[key], (b as Record<string, unknown>)[key])) {
30
+ return false;
31
+ }
32
+ }
33
+
34
+ return true;
35
+ }
@@ -0,0 +1,464 @@
1
+ import type { ReactNode, ComponentType } from "react";
2
+ import type { ResolvedSegment, SlotState } from "../types.js";
3
+ import type { ResolvedThemeConfig, Theme } from "../theme/types.js";
4
+ import type { RenderSegmentsOptions } from "../segment-system.js";
5
+
6
+ // ============================================================================
7
+ // RSC Payload Types
8
+ // ============================================================================
9
+
10
+ /**
11
+ * RSC payload received from server
12
+ */
13
+ export interface RscPayload<TMetadata = RscMetadata> {
14
+ root: ReactNode | Promise<ReactNode> | null;
15
+ metadata?: TMetadata;
16
+ returnValue?: ActionResult;
17
+ formState?: unknown;
18
+ }
19
+
20
+ /**
21
+ * Handle data structure: handleName -> segmentId -> entries[]
22
+ */
23
+ export type HandleData = Record<string, Record<string, unknown[]>>;
24
+
25
+ /**
26
+ * Metadata included in RSC responses
27
+ */
28
+ export interface RscMetadata {
29
+ pathname: string;
30
+ segments: ResolvedSegment[];
31
+ isPartial?: boolean;
32
+ isError?: boolean;
33
+ matched?: string[];
34
+ diff?: string[];
35
+ /**
36
+ * State of named slots for this route match
37
+ * Key is slot name (e.g., "@modal"), value is slot state
38
+ * Slots are used for intercepting routes during soft navigation
39
+ */
40
+ slots?: Record<string, SlotState>;
41
+ /** Root layout component for browser-side re-renders */
42
+ rootLayout?: ComponentType<{ children: ReactNode }>;
43
+ /** Handle data accumulated across route segments (async generator that yields on each push) */
44
+ handles?: AsyncGenerator<HandleData, void, unknown>;
45
+ /** Cached handle data (for back/forward navigation from cache) */
46
+ cachedHandleData?: HandleData;
47
+ /**
48
+ * RSC version string from the server.
49
+ * Used to detect version mismatches after HMR/deployment.
50
+ */
51
+ version?: string;
52
+ /**
53
+ * Theme configuration from router.
54
+ * Included when theme is enabled in router config.
55
+ */
56
+ themeConfig?: ResolvedThemeConfig | null;
57
+ /**
58
+ * Initial theme from cookie (for SSR hydration).
59
+ * Included when theme is enabled in router config.
60
+ */
61
+ initialTheme?: Theme;
62
+ /**
63
+ * Route map for useHref() - maps route names to URL patterns.
64
+ * Used for type-safe URL generation on the client.
65
+ */
66
+ routeMap?: Record<string, string>;
67
+ /**
68
+ * Current matched route name (for local name resolution in useHref).
69
+ * When using include() with name prefix, this contains the full prefixed name.
70
+ */
71
+ routeName?: string;
72
+ }
73
+
74
+ /**
75
+ * Result from server action execution
76
+ */
77
+ export interface ActionResult {
78
+ ok: boolean;
79
+ data: unknown;
80
+ }
81
+
82
+ // ============================================================================
83
+ // Navigation State Types
84
+ // ============================================================================
85
+
86
+ /**
87
+ * Location object representing current URL
88
+ * Uses URL for full URL parsing (origin, host, hostname, port, protocol, searchParams, etc.)
89
+ */
90
+ export type NavigationLocation = URL;
91
+
92
+ /**
93
+ * Inflight server action being tracked
94
+ */
95
+ export interface InflightAction {
96
+ /** Unique identifier for this action invocation */
97
+ id: string;
98
+ /** Server action function ID */
99
+ actionId: string;
100
+ /** Action arguments */
101
+ payload: unknown[];
102
+ /** Timestamp when action started */
103
+ startedAt: number;
104
+ }
105
+
106
+ /**
107
+ * Internal navigation state (includes inflight actions for store use)
108
+ */
109
+ export interface NavigationState {
110
+ /** Navigation lifecycle state (idle or loading during navigation) */
111
+ state: "idle" | "loading";
112
+
113
+ /** Whether RSC data is currently streaming (initial load or navigation) */
114
+ isStreaming: boolean;
115
+
116
+ /** Current location (updated optimistically) */
117
+ location: NavigationLocation;
118
+
119
+ /** URL being navigated to (null when idle) */
120
+ pendingUrl: string | null;
121
+
122
+ /** List of inflight server actions (internal use only) */
123
+ inflightActions: InflightAction[];
124
+ }
125
+
126
+ /**
127
+ * Public navigation state exposed via useNavigation hook
128
+ * Excludes internal properties like inflightActions
129
+ */
130
+ export type PublicNavigationState = Omit<NavigationState, "inflightActions">;
131
+
132
+ // ============================================================================
133
+ // Action State Types (for useAction hook)
134
+ // ============================================================================
135
+
136
+ /**
137
+ * Action lifecycle state
138
+ */
139
+ export type ActionLifecycleState = "idle" | "loading" | "streaming";
140
+
141
+ /**
142
+ * State for a tracked server action
143
+ * Used by useAction hook to observe action lifecycle
144
+ */
145
+ export interface TrackedActionState {
146
+ /** Current lifecycle state of the action */
147
+ state: ActionLifecycleState;
148
+
149
+ /** Server action function ID (e.g., "addToCart") */
150
+ actionId: string | null;
151
+
152
+ /** Action arguments (array for JSON, FormData for form submissions) */
153
+ payload: unknown[] | FormData | null;
154
+
155
+ /** Error if action failed */
156
+ error: unknown | null;
157
+
158
+ /** Result data from the action (preserved after completion) */
159
+ result: unknown | null;
160
+ }
161
+
162
+ /**
163
+ * Listener for action state changes
164
+ */
165
+ export type ActionStateListener = (state: TrackedActionState) => void;
166
+
167
+ /**
168
+ * Cache interface for storing segments
169
+ * Compatible with both Map and LRUCache
170
+ */
171
+ export interface SegmentCache {
172
+ get(key: string): ResolvedSegment | undefined;
173
+ set(key: string, value: ResolvedSegment): void;
174
+ has(key: string): boolean;
175
+ delete(key: string): boolean;
176
+ keys(): IterableIterator<string>;
177
+ readonly size: number;
178
+ }
179
+
180
+ /**
181
+ * Internal segment state managed by the store
182
+ */
183
+ export interface SegmentState {
184
+ path: string;
185
+ currentUrl: string;
186
+ currentSegmentIds: string[];
187
+ }
188
+
189
+ /**
190
+ * Navigation update emitted when UI should re-render
191
+ */
192
+ export interface NavigationUpdate {
193
+ root: ReactNode | Promise<ReactNode>;
194
+ metadata: RscMetadata;
195
+ }
196
+
197
+ /**
198
+ * State value for navigate/Link
199
+ * - LocationStateEntry[]: Type-safe state entries (recommended)
200
+ * - unknown: Legacy format for backwards compatibility
201
+ */
202
+ export type HistoryState = import("./react/location-state-shared.js").LocationStateEntry[] | unknown;
203
+
204
+ /**
205
+ * Options for navigation operations
206
+ */
207
+ export interface NavigateOptions {
208
+ replace?: boolean;
209
+ scroll?: boolean;
210
+ /**
211
+ * State to pass to history.pushState/replaceState
212
+ * Accessible via useLocationState() hook.
213
+ *
214
+ * @example
215
+ * ```tsx
216
+ * // Type-safe state (recommended)
217
+ * const ProductState = createLocationState<{ name: string }>("product");
218
+ * navigate("/product/123", { state: [ProductState({ name: "Widget" })] });
219
+ *
220
+ * // Multiple states
221
+ * navigate("/checkout", { state: [ProductState(p), CartState(c)] });
222
+ *
223
+ * // Legacy format (backwards compatible)
224
+ * navigate("/product", { state: { from: "list" } });
225
+ * ```
226
+ */
227
+ state?: HistoryState;
228
+ }
229
+
230
+ // ============================================================================
231
+ // RSC Browser Dependencies
232
+ // ============================================================================
233
+
234
+ /**
235
+ * RSC runtime functions from @vitejs/plugin-rsc/browser
236
+ *
237
+ * These are injected as dependencies to avoid direct coupling
238
+ * to the RSC runtime implementation.
239
+ */
240
+ export interface RscBrowserDependencies {
241
+ createFromFetch: <T>(
242
+ response: Promise<Response>,
243
+ options?: { temporaryReferences?: any }
244
+ ) => Promise<T>;
245
+ createFromReadableStream: <T>(stream: ReadableStream) => Promise<T>;
246
+ encodeReply: (
247
+ args: any[],
248
+ options?: { temporaryReferences?: any }
249
+ ) => Promise<FormData | string>;
250
+ setServerCallback: (
251
+ callback: (id: string, args: any[]) => Promise<any>
252
+ ) => void;
253
+ createTemporaryReferenceSet: () => any;
254
+ }
255
+
256
+ // ============================================================================
257
+ // Store Types
258
+ // ============================================================================
259
+
260
+ /**
261
+ * Update subscriber callback for UI updates
262
+ */
263
+ export type UpdateSubscriber = (update: NavigationUpdate) => void;
264
+
265
+ /**
266
+ * State change listener for useNavigation hook subscriptions
267
+ */
268
+ export type StateListener = () => void;
269
+
270
+ /**
271
+ * Navigation store interface
272
+ *
273
+ * Manages both:
274
+ * - NavigationState: Public state exposed via useNavigation hook
275
+ * - SegmentState: Internal segment management for partial updates
276
+ */
277
+ export interface NavigationStore {
278
+ // Public state (for useNavigation hook)
279
+ getState(): NavigationState;
280
+ setState(partial: Partial<NavigationState>): void;
281
+ subscribe(listener: StateListener): () => void;
282
+
283
+ // Inflight action management
284
+ addInflightAction(action: InflightAction): void;
285
+ removeInflightAction(id: string): void;
286
+
287
+ // Action state (for controlling update behavior during server actions)
288
+ isActionInProgress(): boolean;
289
+ setActionInProgress(value: boolean): void;
290
+
291
+ // Internal segment state (for bridges)
292
+ getSegmentState(): SegmentState;
293
+ setPath(path: string): void;
294
+ setCurrentUrl(url: string): void;
295
+ setSegmentIds(ids: string[]): void;
296
+
297
+ // History-based segment cache (for back/forward navigation and partial merging)
298
+ getHistoryKey(): string;
299
+ setHistoryKey(key: string): void;
300
+ cacheSegmentsForHistory(
301
+ historyKey: string,
302
+ segments: ResolvedSegment[],
303
+ handleData?: HandleData
304
+ ): void;
305
+ getCachedSegments(
306
+ historyKey: string
307
+ ): { segments: ResolvedSegment[]; stale: boolean; handleData?: HandleData } | undefined;
308
+ hasHistoryCache(historyKey: string): boolean;
309
+ updateCacheHandleData(historyKey: string, handleData: HandleData): void;
310
+ markCacheAsStale(): void;
311
+ markCacheAsStaleAndBroadcast(): void;
312
+ clearHistoryCache(): void;
313
+ broadcastCacheInvalidation(): void;
314
+
315
+ // Cross-tab refresh callback (set by navigation bridge)
316
+ setCrossTabRefreshCallback(callback: () => void): void;
317
+
318
+ // Intercept context tracking (for action revalidation)
319
+ getInterceptSourceUrl(): string | null;
320
+ setInterceptSourceUrl(url: string | null): void;
321
+
322
+ // UI update notifications
323
+ onUpdate(callback: UpdateSubscriber): () => void;
324
+ emitUpdate(update: NavigationUpdate): void;
325
+
326
+ // Action state tracking (for useAction hook)
327
+ getActionState(actionId: string): TrackedActionState;
328
+ setActionState(actionId: string, state: Partial<TrackedActionState>): void;
329
+ subscribeToAction(
330
+ actionId: string,
331
+ listener: ActionStateListener
332
+ ): () => void;
333
+ }
334
+
335
+ // ============================================================================
336
+ // Request Controller Types
337
+ // ============================================================================
338
+
339
+ /**
340
+ * Disposable abort controller with automatic cleanup
341
+ */
342
+ export interface DisposableAbortController extends Disposable {
343
+ controller: AbortController;
344
+ }
345
+
346
+ /**
347
+ * Request controller for managing concurrent requests
348
+ *
349
+ * Separates navigation requests (aborted on new navigation) from
350
+ * action requests (complete independently of navigation).
351
+ */
352
+ export interface RequestController {
353
+ create(): AbortController;
354
+ createDisposable(): DisposableAbortController;
355
+ /** Create a disposable controller for actions (not aborted by navigation) */
356
+ createActionDisposable(): DisposableAbortController;
357
+ /** Abort all navigation requests (not actions) */
358
+ abortAll(): void;
359
+ /** Abort all action requests (used for error handling) */
360
+ abortAllActions(): void;
361
+ remove(controller: AbortController): void;
362
+ }
363
+
364
+ // ============================================================================
365
+ // Navigation Client Types
366
+ // ============================================================================
367
+
368
+ /**
369
+ * Options for partial navigation fetch
370
+ */
371
+ export interface FetchPartialOptions {
372
+ targetUrl: string;
373
+ segmentIds: string[];
374
+ previousUrl: string;
375
+ signal?: AbortSignal;
376
+ /** If true, this is a stale cache revalidation request - server should force revalidators */
377
+ staleRevalidation?: boolean;
378
+ interceptSourceUrl?: string;
379
+ /** RSC version for cache invalidation detection */
380
+ version?: string;
381
+ }
382
+
383
+ /**
384
+ * Result of a partial fetch including stream completion tracking
385
+ */
386
+ export interface FetchPartialResult {
387
+ payload: RscPayload;
388
+ /** Promise that resolves when the response stream is fully consumed */
389
+ streamComplete: Promise<void>;
390
+ }
391
+
392
+ /**
393
+ * Navigation client for fetching RSC payloads
394
+ */
395
+ export interface NavigationClient {
396
+ fetchPartial(options: FetchPartialOptions): Promise<FetchPartialResult>;
397
+ }
398
+
399
+ // ============================================================================
400
+ // Link Interceptor Types
401
+ // ============================================================================
402
+
403
+ /**
404
+ * Options for link interception
405
+ */
406
+ export interface LinkInterceptorOptions {
407
+ shouldIntercept?: (link: HTMLAnchorElement) => boolean;
408
+ }
409
+
410
+ // ============================================================================
411
+ // Server Action Bridge Types
412
+ // ============================================================================
413
+
414
+ /**
415
+ * Server action bridge for handling server actions
416
+ */
417
+ export interface ServerActionBridge {
418
+ register(): void;
419
+ unregister(): void;
420
+ }
421
+
422
+ /**
423
+ * Configuration for server action bridge
424
+ */
425
+ export interface ServerActionBridgeConfig {
426
+ store: NavigationStore;
427
+ client: NavigationClient;
428
+ deps: RscBrowserDependencies;
429
+ onUpdate: UpdateSubscriber;
430
+ renderSegments: (
431
+ segments: ResolvedSegment[],
432
+ options?: RenderSegmentsOptions
433
+ ) => Promise<ReactNode> | ReactNode;
434
+ }
435
+
436
+ // ============================================================================
437
+ // Navigation Bridge Types
438
+ // ============================================================================
439
+
440
+ /**
441
+ * Navigation bridge for handling client-side navigation
442
+ */
443
+ export interface NavigationBridge {
444
+ navigate(url: string, options?: NavigateOptions): Promise<void>;
445
+ refresh(): Promise<void>;
446
+ handlePopstate(): Promise<void>;
447
+ registerLinkInterception(): () => void;
448
+ }
449
+
450
+ /**
451
+ * Configuration for navigation bridge
452
+ */
453
+ export interface NavigationBridgeConfig {
454
+ store: NavigationStore;
455
+ client: NavigationClient;
456
+ onUpdate: UpdateSubscriber;
457
+ renderSegments: (
458
+ segments: ResolvedSegment[],
459
+ options?: RenderSegmentsOptions
460
+ ) => Promise<ReactNode> | ReactNode;
461
+ }
462
+
463
+ // Re-export ResolvedSegment for convenience
464
+ export type { ResolvedSegment };