@rangojs/router 0.0.0-experimental.4518794d → 0.0.0-experimental.52ff0316
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/vite/index.js
CHANGED
|
@@ -1745,7 +1745,7 @@ import { resolve } from "node:path";
|
|
|
1745
1745
|
// package.json
|
|
1746
1746
|
var package_default = {
|
|
1747
1747
|
name: "@rangojs/router",
|
|
1748
|
-
version: "0.0.0-experimental.
|
|
1748
|
+
version: "0.0.0-experimental.52ff0316",
|
|
1749
1749
|
description: "Django-inspired RSC router with composable URL patterns",
|
|
1750
1750
|
keywords: [
|
|
1751
1751
|
"react",
|
package/package.json
CHANGED
|
@@ -7,6 +7,7 @@ import type {
|
|
|
7
7
|
import { generateHistoryKey } from "./navigation-store.js";
|
|
8
8
|
import {
|
|
9
9
|
handleNavigationStart,
|
|
10
|
+
handleNavigationEnd,
|
|
10
11
|
ensureHistoryKey,
|
|
11
12
|
} from "./scroll-restoration.js";
|
|
12
13
|
import type { EventController, NavigationHandle } from "./event-controller.js";
|
|
@@ -80,12 +81,11 @@ export interface BoundTransaction {
|
|
|
80
81
|
readonly currentUrl: string;
|
|
81
82
|
/** Start streaming and get a token to end it when the stream completes */
|
|
82
83
|
startStreaming(): StreamingToken;
|
|
83
|
-
/** Commit the navigation. Returns the effective scroll option for the caller to handle. */
|
|
84
84
|
commit(
|
|
85
85
|
segmentIds: string[],
|
|
86
86
|
segments: ResolvedSegment[],
|
|
87
87
|
overrides?: BoundCommitOverrides,
|
|
88
|
-
):
|
|
88
|
+
): void;
|
|
89
89
|
}
|
|
90
90
|
|
|
91
91
|
/**
|
|
@@ -93,7 +93,7 @@ export interface BoundTransaction {
|
|
|
93
93
|
* Uses the event controller handle for lifecycle management
|
|
94
94
|
*/
|
|
95
95
|
interface NavigationTransaction extends Disposable {
|
|
96
|
-
commit(options: CommitOptions):
|
|
96
|
+
commit(options: CommitOptions): void;
|
|
97
97
|
with(
|
|
98
98
|
options: Omit<CommitOptions, "segmentIds" | "segments">,
|
|
99
99
|
): BoundTransaction;
|
|
@@ -120,7 +120,7 @@ export function createNavigationTransaction(
|
|
|
120
120
|
/**
|
|
121
121
|
* Commit the navigation - updates store and URL atomically
|
|
122
122
|
*/
|
|
123
|
-
function commit(opts: CommitOptions):
|
|
123
|
+
function commit(opts: CommitOptions): void {
|
|
124
124
|
committed = true;
|
|
125
125
|
|
|
126
126
|
const {
|
|
@@ -150,7 +150,7 @@ export function createNavigationTransaction(
|
|
|
150
150
|
// Without this, the entry lingers and weakens state-machine invariants.
|
|
151
151
|
handle.complete(parsedUrl);
|
|
152
152
|
debugLog("[Browser] Cache-only commit, historyKey:", historyKey);
|
|
153
|
-
return
|
|
153
|
+
return;
|
|
154
154
|
}
|
|
155
155
|
|
|
156
156
|
// Save current scroll position before navigating
|
|
@@ -172,7 +172,7 @@ export function createNavigationTransaction(
|
|
|
172
172
|
debugLog("[Browser] Store updated (action)");
|
|
173
173
|
// Complete navigation to clear loading state
|
|
174
174
|
handle.complete(parsedUrl);
|
|
175
|
-
return
|
|
175
|
+
return;
|
|
176
176
|
}
|
|
177
177
|
|
|
178
178
|
// Build history state - include user state, intercept info, and server-set state
|
|
@@ -205,16 +205,14 @@ export function createNavigationTransaction(
|
|
|
205
205
|
// Complete the navigation in event controller (sets idle state, updates location)
|
|
206
206
|
handle.complete(parsedUrl);
|
|
207
207
|
|
|
208
|
-
//
|
|
209
|
-
|
|
208
|
+
// Handle scroll after navigation
|
|
209
|
+
handleNavigationEnd({ scroll });
|
|
210
210
|
|
|
211
211
|
debugLog(
|
|
212
212
|
"[Browser] Navigation committed, historyKey:",
|
|
213
213
|
historyKey,
|
|
214
214
|
intercept ? "(intercept)" : "",
|
|
215
215
|
);
|
|
216
|
-
|
|
217
|
-
return { scroll };
|
|
218
216
|
}
|
|
219
217
|
|
|
220
218
|
return {
|
|
@@ -265,7 +263,7 @@ export function createNavigationTransaction(
|
|
|
265
263
|
overrides?.state !== undefined ? overrides.state : opts.state;
|
|
266
264
|
// Server-set location state: only from overrides (set by partial-update)
|
|
267
265
|
const serverState = overrides?.serverState;
|
|
268
|
-
|
|
266
|
+
commit({
|
|
269
267
|
...opts,
|
|
270
268
|
segmentIds,
|
|
271
269
|
segments,
|
|
@@ -19,7 +19,6 @@ import type { BoundTransaction } from "./navigation-transaction.js";
|
|
|
19
19
|
import { ServerRedirect } from "../errors.js";
|
|
20
20
|
import { debugLog } from "./logging.js";
|
|
21
21
|
import { validateRedirectOrigin } from "./validate-redirect-origin.js";
|
|
22
|
-
import { handleNavigationEnd } from "./scroll-restoration.js";
|
|
23
22
|
|
|
24
23
|
/**
|
|
25
24
|
* Configuration for creating a partial updater
|
|
@@ -247,10 +246,7 @@ export function createPartialUpdater(
|
|
|
247
246
|
forceAwait: true,
|
|
248
247
|
});
|
|
249
248
|
|
|
250
|
-
|
|
251
|
-
matchedIds,
|
|
252
|
-
existingSegments,
|
|
253
|
-
);
|
|
249
|
+
tx.commit(matchedIds, existingSegments);
|
|
254
250
|
|
|
255
251
|
// Include cachedHandleData in metadata so NavigationProvider can restore
|
|
256
252
|
// breadcrumbs and other handle data from cache.
|
|
@@ -280,7 +276,6 @@ export function createPartialUpdater(
|
|
|
280
276
|
onUpdate(cachedUpdate);
|
|
281
277
|
}
|
|
282
278
|
|
|
283
|
-
handleNavigationEnd({ scroll: commitScroll });
|
|
284
279
|
debugLog("[Browser] Navigation complete (rendered from cache)");
|
|
285
280
|
return;
|
|
286
281
|
}
|
|
@@ -295,17 +290,13 @@ export function createPartialUpdater(
|
|
|
295
290
|
forceAwait: true,
|
|
296
291
|
});
|
|
297
292
|
|
|
298
|
-
|
|
299
|
-
matchedIds,
|
|
300
|
-
existingSegments,
|
|
301
|
-
);
|
|
293
|
+
tx.commit(matchedIds, existingSegments);
|
|
302
294
|
|
|
303
295
|
onUpdate({
|
|
304
296
|
root: newTree,
|
|
305
297
|
metadata: payload.metadata,
|
|
306
298
|
});
|
|
307
299
|
|
|
308
|
-
handleNavigationEnd({ scroll: leaveScroll });
|
|
309
300
|
debugLog("[Browser] Navigation complete (left intercept)");
|
|
310
301
|
return;
|
|
311
302
|
}
|
|
@@ -435,11 +426,7 @@ export function createPartialUpdater(
|
|
|
435
426
|
: serverLocationState
|
|
436
427
|
? { serverState: serverLocationState }
|
|
437
428
|
: undefined;
|
|
438
|
-
|
|
439
|
-
allSegmentIds,
|
|
440
|
-
reconciled.segments,
|
|
441
|
-
overrides,
|
|
442
|
-
);
|
|
429
|
+
tx.commit(allSegmentIds, reconciled.segments, overrides);
|
|
443
430
|
|
|
444
431
|
// For stale revalidation: verify history key hasn't changed before updating UI
|
|
445
432
|
if (mode.type === "stale-revalidation") {
|
|
@@ -484,9 +471,6 @@ export function createPartialUpdater(
|
|
|
484
471
|
});
|
|
485
472
|
}
|
|
486
473
|
|
|
487
|
-
// Scroll after onUpdate so React has the new content before we scroll
|
|
488
|
-
handleNavigationEnd({ scroll: navScroll });
|
|
489
|
-
|
|
490
474
|
debugLog("[Browser] Navigation complete");
|
|
491
475
|
return;
|
|
492
476
|
} else {
|
|
@@ -510,11 +494,11 @@ export function createPartialUpdater(
|
|
|
510
494
|
}
|
|
511
495
|
|
|
512
496
|
const fullUpdateServerState = payload.metadata?.locationState;
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
497
|
+
if (fullUpdateServerState) {
|
|
498
|
+
tx.commit(segmentIds, segments, { serverState: fullUpdateServerState });
|
|
499
|
+
} else {
|
|
500
|
+
tx.commit(segmentIds, segments);
|
|
501
|
+
}
|
|
518
502
|
|
|
519
503
|
const fullHasTransition = segments.some(
|
|
520
504
|
(s: ResolvedSegment) => s.transition,
|
|
@@ -558,7 +542,6 @@ export function createPartialUpdater(
|
|
|
558
542
|
});
|
|
559
543
|
}
|
|
560
544
|
|
|
561
|
-
handleNavigationEnd({ scroll: fullScroll });
|
|
562
545
|
return;
|
|
563
546
|
}
|
|
564
547
|
}
|
|
@@ -370,21 +370,13 @@ export function handleNavigationEnd(options: {
|
|
|
370
370
|
// Fall through to hash or top if no saved position
|
|
371
371
|
}
|
|
372
372
|
|
|
373
|
-
//
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
? requestAnimationFrame
|
|
378
|
-
: (fn: () => void) => setTimeout(fn, 0);
|
|
379
|
-
defer(() => {
|
|
380
|
-
// Try hash scrolling first
|
|
381
|
-
if (scrollToHash()) {
|
|
382
|
-
return;
|
|
383
|
-
}
|
|
373
|
+
// Try hash scrolling first
|
|
374
|
+
if (scrollToHash()) {
|
|
375
|
+
return;
|
|
376
|
+
}
|
|
384
377
|
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
});
|
|
378
|
+
// Default: scroll to top
|
|
379
|
+
scrollToTop();
|
|
388
380
|
}
|
|
389
381
|
|
|
390
382
|
/**
|