@teyik0/furin 0.9.0-alpha.3 → 0.9.0-alpha.5
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/adapter/runtime-build.d.ts +1 -0
- package/dist/build/index.js +65 -25
- package/dist/build/route-metadata.d.ts +1 -1
- package/dist/cli/index.js +65 -25
- package/dist/client/chunks/{client-rdxyrw11.js → client-hjqd5m3b.js} +1 -1
- package/dist/client/chunks/{client-d9v49jwz.js → client-whph3y67.js} +66 -3
- package/dist/client/chunks/{client-a7spxfnn.js → client-xf7r768c.js} +13 -1
- package/dist/client/define-route.d.ts +12 -0
- package/dist/client/internal/runtime-types.d.ts +7 -0
- package/dist/client/link.js +200 -40
- package/dist/client/query.d.ts +13 -0
- package/dist/client/route-element.d.ts +5 -0
- package/dist/client/router/history.d.ts +6 -0
- package/dist/client/router/link-utils.d.ts +7 -0
- package/dist/client/router/navigation-controller.d.ts +20 -2
- package/dist/client/router/pending.d.ts +17 -0
- package/dist/client/router/search/index.d.ts +2 -0
- package/dist/client/router/search/index.js +7 -3
- package/dist/client/router/types.d.ts +21 -1
- package/dist/client.d.ts +1 -1
- package/dist/client.js +21 -4
- package/dist/define-route.d.ts +37 -10
- package/dist/furin.js +92 -43
- package/dist/plugin/client-plugin.d.ts +1 -1
- package/dist/plugin/index.js +36 -17
- package/dist/plugin/route-manifest.d.ts +2 -1
- package/dist/plugin/strip-server-stages.d.ts +1 -1
- package/dist/server/dev/graph.d.ts +0 -1
- package/dist/server/internal.d.ts +1 -0
- package/dist/server/internal.js +46 -22
- package/dist/server/router/defined-route.d.ts +3 -0
- package/dist/server/router/hmr.d.ts +0 -1
- package/dist/server/router/source-version.d.ts +0 -1
- package/dist/server/router/types.d.ts +7 -1
- package/dist/server/static-export.js +49 -22
- package/dist/server/sync/index.js +1 -1
- package/dist/shared/pending.d.ts +13 -0
- package/dist/shared/search-params.d.ts +1 -0
- package/dist/sync-client.js +1 -1
- package/package.json +1 -1
- package/src/adapter/runtime-build.ts +4 -0
- package/src/build/hydrate.ts +11 -2
- package/src/build/preload-manifest.ts +3 -1
- package/src/build/route-metadata.ts +3 -2
- package/src/client/define-route.ts +23 -3
- package/src/client/internal/runtime-types.ts +7 -0
- package/src/client/link.tsx +26 -4
- package/src/client/query-store.ts +2 -1
- package/src/client/query.tsx +87 -0
- package/src/client/route-element.tsx +41 -15
- package/src/client/router/context.ts +29 -8
- package/src/client/router/history.ts +10 -0
- package/src/client/router/link-utils.ts +23 -0
- package/src/client/router/navigation-controller.ts +239 -19
- package/src/client/router/pending.ts +58 -0
- package/src/client/router/provider.tsx +5 -2
- package/src/client/router/search/index.ts +7 -2
- package/src/client/router/types.ts +29 -3
- package/src/client.ts +1 -1
- package/src/define-route.ts +74 -26
- package/src/plugin/client-plugin.ts +5 -4
- package/src/plugin/route-config.ts +9 -2
- package/src/plugin/route-manifest.ts +11 -3
- package/src/plugin/route-tree.ts +2 -2
- package/src/plugin/strip-server-stages.ts +60 -35
- package/src/server/dev/graph.ts +2 -7
- package/src/server/dev/runtime.ts +1 -2
- package/src/server/internal.ts +1 -0
- package/src/server/router/defined-route.ts +6 -0
- package/src/server/router/discovery.ts +5 -2
- package/src/server/router/hmr.ts +1 -5
- package/src/server/router/source-version.ts +3 -6
- package/src/server/router/types.ts +7 -1
- package/src/shared/pending.ts +16 -0
- package/src/shared/search-params.ts +1 -1
package/dist/server/internal.js
CHANGED
|
@@ -3208,6 +3208,18 @@ function applyLinkParams(to, params) {
|
|
|
3208
3208
|
}
|
|
3209
3209
|
return url;
|
|
3210
3210
|
}
|
|
3211
|
+
function resolveTargetSearch(path, search, routes) {
|
|
3212
|
+
if (path.includes("?")) {
|
|
3213
|
+
return;
|
|
3214
|
+
}
|
|
3215
|
+
const resolved = { ...findSearchDefaultsForRouteTarget(path, routes) };
|
|
3216
|
+
for (const [key, value] of Object.entries(search ?? {})) {
|
|
3217
|
+
if (value !== null && value !== undefined) {
|
|
3218
|
+
resolved[key] = value;
|
|
3219
|
+
}
|
|
3220
|
+
}
|
|
3221
|
+
return resolved;
|
|
3222
|
+
}
|
|
3211
3223
|
function buildHref(to, search, hash, searchDefaults) {
|
|
3212
3224
|
let url = to;
|
|
3213
3225
|
if (search && Object.keys(search).length > 0) {
|
|
@@ -3363,7 +3375,6 @@ class DevGraph {
|
|
|
3363
3375
|
#eventSequence = 0;
|
|
3364
3376
|
#revision = 0;
|
|
3365
3377
|
#snapshot;
|
|
3366
|
-
#sourceGeneration = 0;
|
|
3367
3378
|
constructor(initialSnapshot) {
|
|
3368
3379
|
this.#snapshot = initialSnapshot;
|
|
3369
3380
|
}
|
|
@@ -3566,9 +3577,6 @@ class DevGraph {
|
|
|
3566
3577
|
}
|
|
3567
3578
|
}
|
|
3568
3579
|
}
|
|
3569
|
-
invalidateModules() {
|
|
3570
|
-
this.#sourceGeneration += 1;
|
|
3571
|
-
}
|
|
3572
3580
|
sourceVersion(path) {
|
|
3573
3581
|
const modulePath = normalizeModulePath(path);
|
|
3574
3582
|
const fingerprint = this.#sourceFingerprint(modulePath, new Set);
|
|
@@ -3588,9 +3596,9 @@ class DevGraph {
|
|
|
3588
3596
|
let ownFingerprint;
|
|
3589
3597
|
try {
|
|
3590
3598
|
const stats = statSync(path, { bigint: true });
|
|
3591
|
-
ownFingerprint = `${stats.mtimeNs}:${stats.size}
|
|
3599
|
+
ownFingerprint = `${stats.mtimeNs}:${stats.size}`;
|
|
3592
3600
|
} catch {
|
|
3593
|
-
ownFingerprint =
|
|
3601
|
+
ownFingerprint = "missing";
|
|
3594
3602
|
}
|
|
3595
3603
|
const dependencies = [...this.#dependencies.get(path) ?? []].toSorted((left, right) => left.localeCompare(right)).map((dependency) => this.#sourceFingerprint(dependency, visited));
|
|
3596
3604
|
return `${path}:${ownFingerprint}:${dependencies.join(",")}`;
|
|
@@ -4787,10 +4795,10 @@ class QueryStore {
|
|
|
4787
4795
|
}
|
|
4788
4796
|
}
|
|
4789
4797
|
entry.snapshot = { ...entry.snapshot, data };
|
|
4798
|
+
this.revisionValue += 1;
|
|
4790
4799
|
for (const listener of entry.listeners) {
|
|
4791
4800
|
listener();
|
|
4792
4801
|
}
|
|
4793
|
-
this.revisionValue += 1;
|
|
4794
4802
|
for (const listener of this.listeners) {
|
|
4795
4803
|
listener();
|
|
4796
4804
|
}
|
|
@@ -6142,6 +6150,7 @@ import {
|
|
|
6142
6150
|
useCallback,
|
|
6143
6151
|
useContext as useContext2,
|
|
6144
6152
|
useEffect,
|
|
6153
|
+
useState,
|
|
6145
6154
|
useSyncExternalStore
|
|
6146
6155
|
} from "react";
|
|
6147
6156
|
var QUERY_CONTEXT2 = Symbol.for("furin.query.context.v1");
|
|
@@ -8515,7 +8524,14 @@ function withDocumentState(element, assets, head, data, nonce, jsonCompatible) {
|
|
|
8515
8524
|
|
|
8516
8525
|
// src/client/link.tsx
|
|
8517
8526
|
init_search_params();
|
|
8518
|
-
import {
|
|
8527
|
+
import {
|
|
8528
|
+
createElement as createElement6,
|
|
8529
|
+
useCallback as useCallback3,
|
|
8530
|
+
useEffect as useEffect2,
|
|
8531
|
+
useMemo as useMemo2,
|
|
8532
|
+
useRef,
|
|
8533
|
+
useSyncExternalStore as useSyncExternalStore2
|
|
8534
|
+
} from "react";
|
|
8519
8535
|
|
|
8520
8536
|
// src/client/router/context.ts
|
|
8521
8537
|
init_link_utils();
|
|
@@ -8784,6 +8800,18 @@ function selectRouteBoundary(boundaries, rootBoundary, index, kind) {
|
|
|
8784
8800
|
function wrapLayout(route, props, element) {
|
|
8785
8801
|
return route?.layout ? createElement5(route.layout, props, element) : element;
|
|
8786
8802
|
}
|
|
8803
|
+
function wrapSegments(input, depth, props, fallbackProps, element) {
|
|
8804
|
+
let wrapped = element;
|
|
8805
|
+
for (let layout = depth;layout >= 0; layout -= 1) {
|
|
8806
|
+
for (const boundary of input.boundaries.toReversed()) {
|
|
8807
|
+
if (boundary.depth === layout) {
|
|
8808
|
+
wrapped = wrapSegmentBoundaries(wrapped, boundary, input.boundaryOptions);
|
|
8809
|
+
}
|
|
8810
|
+
}
|
|
8811
|
+
wrapped = wrapLayout(input.chain[layout], props[layout] ?? fallbackProps, wrapped);
|
|
8812
|
+
}
|
|
8813
|
+
return wrapped;
|
|
8814
|
+
}
|
|
8787
8815
|
function failureElement(failure, component, reset) {
|
|
8788
8816
|
if (failure.status === "error") {
|
|
8789
8817
|
return createElement5(component ?? DefaultErrorFallback, {
|
|
@@ -8808,9 +8836,10 @@ function resolveRouteElement(input) {
|
|
|
8808
8836
|
inherited = { ...inherited, ...match.loaderData };
|
|
8809
8837
|
props.push({ ...inherited, ...context });
|
|
8810
8838
|
}
|
|
8839
|
+
const { pending } = input;
|
|
8811
8840
|
const index = matches.findIndex((match) => match.status !== "success");
|
|
8812
8841
|
const failure = matches[index];
|
|
8813
|
-
if (failure && failure.status !== "success") {
|
|
8842
|
+
if (failure && failure.status !== "success" && !pending) {
|
|
8814
8843
|
const { component, depth } = selectRouteBoundary(boundaries, input.rootBoundary, index, failure.status);
|
|
8815
8844
|
let element = failureElement(failure, component, input.reset);
|
|
8816
8845
|
for (let layout = depth;layout >= 0; layout -= 1) {
|
|
@@ -8822,18 +8851,10 @@ function resolveRouteElement(input) {
|
|
|
8822
8851
|
throw new Error("[furin] internal invariant: a successful route render requires a page.");
|
|
8823
8852
|
}
|
|
8824
8853
|
const pageProps = Object.fromEntries(Object.entries(data).filter(([key]) => !key.startsWith("__furin")));
|
|
8825
|
-
|
|
8854
|
+
const element = pending ? wrapSegments(input, pending.depth, props, pageProps, createElement5(pending.component)) : wrapSegments(input, chain.length - 1, props, pageProps, createElement5(page.component, {
|
|
8826
8855
|
...pageProps,
|
|
8827
8856
|
key: pageKey(page.pattern, pageProps, chain.at(-1)?.remountDeps)
|
|
8828
|
-
});
|
|
8829
|
-
for (let layout = chain.length - 1;layout >= 0; layout -= 1) {
|
|
8830
|
-
for (const boundary of boundaries.toReversed()) {
|
|
8831
|
-
if (boundary.depth === layout) {
|
|
8832
|
-
element = wrapSegmentBoundaries(element, boundary, input.boundaryOptions);
|
|
8833
|
-
}
|
|
8834
|
-
}
|
|
8835
|
-
element = wrapLayout(chain[layout], props[layout] ?? pageProps, element);
|
|
8836
|
-
}
|
|
8857
|
+
}));
|
|
8837
8858
|
return withRouteSnapshot(element, page.pattern, pageProps);
|
|
8838
8859
|
}
|
|
8839
8860
|
|
|
@@ -8940,6 +8961,7 @@ function LinkInteractive({
|
|
|
8940
8961
|
replace,
|
|
8941
8962
|
disabled,
|
|
8942
8963
|
resetScroll,
|
|
8964
|
+
shallow,
|
|
8943
8965
|
activeProps,
|
|
8944
8966
|
inactiveProps,
|
|
8945
8967
|
onClick,
|
|
@@ -8955,6 +8977,7 @@ function LinkInteractive({
|
|
|
8955
8977
|
const anchorRef = useRef(null);
|
|
8956
8978
|
const intentTimerRef = useRef(null);
|
|
8957
8979
|
const { activeHref, logicalHref, href } = resolveLinkHref({ hash, params, search, to }, router2);
|
|
8980
|
+
const targetSearch = useMemo2(() => resolveTargetSearch(applyLinkParams(to, params), search, router2.searchRoutes), [logicalHref, router2.searchRoutes]);
|
|
8958
8981
|
const isActive = useSyncExternalStore2(store.subscribe, () => activeHref !== undefined && store.getCurrentHref() === activeHref, () => activeHref !== undefined && store.getCurrentHref() === activeHref);
|
|
8959
8982
|
const { resolvedChildren, extraProps } = resolveLinkState({ activeProps, children, inactiveProps }, isActive);
|
|
8960
8983
|
const effectivePreload = preload ?? router2.defaultPreload;
|
|
@@ -8968,9 +8991,9 @@ function LinkInteractive({
|
|
|
8968
8991
|
}
|
|
8969
8992
|
const target = shouldInterceptClick(anchor, { altKey: false, ctrlKey: false, metaKey: false, shiftKey: false }, router2.basePath, window.location.origin, window.location.pathname);
|
|
8970
8993
|
if (target !== null) {
|
|
8971
|
-
prefetch(target, { staleTime: effectiveStaleTime });
|
|
8994
|
+
prefetch(target, { search: targetSearch, staleTime: effectiveStaleTime });
|
|
8972
8995
|
}
|
|
8973
|
-
}, [prefetch, effectiveStaleTime, router2.basePath]);
|
|
8996
|
+
}, [prefetch, effectiveStaleTime, router2.basePath, targetSearch]);
|
|
8974
8997
|
useEffect2(() => {
|
|
8975
8998
|
if (effectivePreload === "render") {
|
|
8976
8999
|
triggerPrefetch();
|
|
@@ -9020,7 +9043,7 @@ function LinkInteractive({
|
|
|
9020
9043
|
window.location.assign(href);
|
|
9021
9044
|
return;
|
|
9022
9045
|
}
|
|
9023
|
-
router2.navigate(target, { replace, resetScroll:
|
|
9046
|
+
router2.navigate(target, { replace, resetScroll, search: targetSearch, shallow });
|
|
9024
9047
|
};
|
|
9025
9048
|
const handleMouseEnter = (e) => {
|
|
9026
9049
|
onMouseEnter?.(e);
|
|
@@ -9088,6 +9111,7 @@ function renderLinkElement(props, router2) {
|
|
|
9088
9111
|
preloadStaleTime: _ps,
|
|
9089
9112
|
replace: _r,
|
|
9090
9113
|
resetScroll: _rs,
|
|
9114
|
+
shallow: _sh,
|
|
9091
9115
|
onClick: _oc,
|
|
9092
9116
|
onMouseEnter: _ome,
|
|
9093
9117
|
onMouseLeave: _oml,
|
|
@@ -3,6 +3,7 @@ import type { HeadOptions, RenderingMode } from "../../client.ts";
|
|
|
3
3
|
import type { ErrorComponent } from "../../shared/error.ts";
|
|
4
4
|
import type { NotFoundComponent } from "../../shared/not-found.ts";
|
|
5
5
|
import type { RemountDependency } from "../../shared/page-key.ts";
|
|
6
|
+
import type { RoutePending } from "../../shared/pending.ts";
|
|
6
7
|
interface DefinedRouteTerminal {
|
|
7
8
|
__type: "FURIN_ROUTE";
|
|
8
9
|
component: (...args: never[]) => React.ReactNode;
|
|
@@ -11,9 +12,11 @@ interface DefinedRouteTerminal {
|
|
|
11
12
|
head?: (...args: never[]) => HeadOptions;
|
|
12
13
|
layout?: (...args: never[]) => React.ReactNode;
|
|
13
14
|
loader?: (...args: never[]) => unknown;
|
|
15
|
+
loaderDeps?: (query: never) => object;
|
|
14
16
|
mode?: RenderingMode;
|
|
15
17
|
notFoundComponent?: NotFoundComponent;
|
|
16
18
|
page?: (...args: never[]) => React.ReactNode;
|
|
19
|
+
pending?: RoutePending;
|
|
17
20
|
remountDeps?: (context: never) => readonly RemountDependency[];
|
|
18
21
|
requestLoader?: (...args: never[]) => unknown;
|
|
19
22
|
revalidate?: number;
|
|
@@ -11,7 +11,6 @@ type RouteModuleImport = (specifier: string) => Promise<CompiledModule>;
|
|
|
11
11
|
* requests for the same edited version.
|
|
12
12
|
*/
|
|
13
13
|
export declare function importStampedRouteModule(path: string, resolveImport: RouteModuleImport): Promise<CompiledModule>;
|
|
14
|
-
export declare function invalidateStampedRouteModules(): void;
|
|
15
14
|
/**
|
|
16
15
|
* Re-imports the page's layouts (`layoutPaths`, shallow → deep, as the route
|
|
17
16
|
* manifest lists them) with a versioned module identity, then patches the
|
|
@@ -34,6 +34,11 @@ export interface SegmentBoundary {
|
|
|
34
34
|
* except the root's, which is the pages directory.
|
|
35
35
|
*/
|
|
36
36
|
path: string;
|
|
37
|
+
/**
|
|
38
|
+
* Module declaring the pending screen: a `loading.tsx`, or the route file
|
|
39
|
+
* of a `fromRoute` boundary. Only the client renders it.
|
|
40
|
+
*/
|
|
41
|
+
pendingPath?: string;
|
|
37
42
|
}
|
|
38
43
|
/** A layout wrapping a page, from the route manifest. */
|
|
39
44
|
export interface ResolvedLayout {
|
|
@@ -59,7 +64,8 @@ export interface ResolvedRoute {
|
|
|
59
64
|
routeChain: RuntimeRoute[];
|
|
60
65
|
/**
|
|
61
66
|
* Per-directory boundary chain, ordered shallow → deep. Only directories
|
|
62
|
-
* that DECLARE at least one of `error.tsx` / `not-found.tsx`
|
|
67
|
+
* that DECLARE at least one of `error.tsx` / `not-found.tsx` / `loading.tsx`
|
|
68
|
+
* (or routes with `.error()` / `.notFound()` / `.pending()`) are included;
|
|
63
69
|
* directories without conventions are skipped. Empty when no conventions
|
|
64
70
|
* exist anywhere in the path.
|
|
65
71
|
*/
|
|
@@ -3200,6 +3200,18 @@ function applyLinkParams(to, params) {
|
|
|
3200
3200
|
}
|
|
3201
3201
|
return url;
|
|
3202
3202
|
}
|
|
3203
|
+
function resolveTargetSearch(path, search, routes) {
|
|
3204
|
+
if (path.includes("?")) {
|
|
3205
|
+
return;
|
|
3206
|
+
}
|
|
3207
|
+
const resolved = { ...findSearchDefaultsForRouteTarget(path, routes) };
|
|
3208
|
+
for (const [key, value] of Object.entries(search ?? {})) {
|
|
3209
|
+
if (value !== null && value !== undefined) {
|
|
3210
|
+
resolved[key] = value;
|
|
3211
|
+
}
|
|
3212
|
+
}
|
|
3213
|
+
return resolved;
|
|
3214
|
+
}
|
|
3203
3215
|
function buildHref(to, search, hash, searchDefaults) {
|
|
3204
3216
|
let url = to;
|
|
3205
3217
|
if (search && Object.keys(search).length > 0) {
|
|
@@ -3355,7 +3367,6 @@ class DevGraph {
|
|
|
3355
3367
|
#eventSequence = 0;
|
|
3356
3368
|
#revision = 0;
|
|
3357
3369
|
#snapshot;
|
|
3358
|
-
#sourceGeneration = 0;
|
|
3359
3370
|
constructor(initialSnapshot) {
|
|
3360
3371
|
this.#snapshot = initialSnapshot;
|
|
3361
3372
|
}
|
|
@@ -3558,9 +3569,6 @@ class DevGraph {
|
|
|
3558
3569
|
}
|
|
3559
3570
|
}
|
|
3560
3571
|
}
|
|
3561
|
-
invalidateModules() {
|
|
3562
|
-
this.#sourceGeneration += 1;
|
|
3563
|
-
}
|
|
3564
3572
|
sourceVersion(path) {
|
|
3565
3573
|
const modulePath = normalizeModulePath(path);
|
|
3566
3574
|
const fingerprint = this.#sourceFingerprint(modulePath, new Set);
|
|
@@ -3580,9 +3588,9 @@ class DevGraph {
|
|
|
3580
3588
|
let ownFingerprint;
|
|
3581
3589
|
try {
|
|
3582
3590
|
const stats = statSync(path, { bigint: true });
|
|
3583
|
-
ownFingerprint = `${stats.mtimeNs}:${stats.size}
|
|
3591
|
+
ownFingerprint = `${stats.mtimeNs}:${stats.size}`;
|
|
3584
3592
|
} catch {
|
|
3585
|
-
ownFingerprint =
|
|
3593
|
+
ownFingerprint = "missing";
|
|
3586
3594
|
}
|
|
3587
3595
|
const dependencies = [...this.#dependencies.get(path) ?? []].toSorted((left, right) => left.localeCompare(right)).map((dependency) => this.#sourceFingerprint(dependency, visited));
|
|
3588
3596
|
return `${path}:${ownFingerprint}:${dependencies.join(",")}`;
|
|
@@ -4617,10 +4625,10 @@ class QueryStore {
|
|
|
4617
4625
|
}
|
|
4618
4626
|
}
|
|
4619
4627
|
entry.snapshot = { ...entry.snapshot, data };
|
|
4628
|
+
this.revisionValue += 1;
|
|
4620
4629
|
for (const listener of entry.listeners) {
|
|
4621
4630
|
listener();
|
|
4622
4631
|
}
|
|
4623
|
-
this.revisionValue += 1;
|
|
4624
4632
|
for (const listener of this.listeners) {
|
|
4625
4633
|
listener();
|
|
4626
4634
|
}
|
|
@@ -5948,6 +5956,7 @@ import {
|
|
|
5948
5956
|
useCallback,
|
|
5949
5957
|
useContext as useContext2,
|
|
5950
5958
|
useEffect,
|
|
5959
|
+
useState,
|
|
5951
5960
|
useSyncExternalStore
|
|
5952
5961
|
} from "react";
|
|
5953
5962
|
var QUERY_CONTEXT2 = Symbol.for("furin.query.context.v1");
|
|
@@ -8321,7 +8330,14 @@ function withDocumentState(element, assets, head, data, nonce, jsonCompatible) {
|
|
|
8321
8330
|
|
|
8322
8331
|
// src/client/link.tsx
|
|
8323
8332
|
init_search_params();
|
|
8324
|
-
import {
|
|
8333
|
+
import {
|
|
8334
|
+
createElement as createElement6,
|
|
8335
|
+
useCallback as useCallback3,
|
|
8336
|
+
useEffect as useEffect2,
|
|
8337
|
+
useMemo as useMemo2,
|
|
8338
|
+
useRef,
|
|
8339
|
+
useSyncExternalStore as useSyncExternalStore2
|
|
8340
|
+
} from "react";
|
|
8325
8341
|
|
|
8326
8342
|
// src/client/router/context.ts
|
|
8327
8343
|
init_link_utils();
|
|
@@ -8590,6 +8606,18 @@ function selectRouteBoundary(boundaries, rootBoundary, index, kind) {
|
|
|
8590
8606
|
function wrapLayout(route, props, element) {
|
|
8591
8607
|
return route?.layout ? createElement5(route.layout, props, element) : element;
|
|
8592
8608
|
}
|
|
8609
|
+
function wrapSegments(input, depth, props, fallbackProps, element) {
|
|
8610
|
+
let wrapped = element;
|
|
8611
|
+
for (let layout = depth;layout >= 0; layout -= 1) {
|
|
8612
|
+
for (const boundary of input.boundaries.toReversed()) {
|
|
8613
|
+
if (boundary.depth === layout) {
|
|
8614
|
+
wrapped = wrapSegmentBoundaries(wrapped, boundary, input.boundaryOptions);
|
|
8615
|
+
}
|
|
8616
|
+
}
|
|
8617
|
+
wrapped = wrapLayout(input.chain[layout], props[layout] ?? fallbackProps, wrapped);
|
|
8618
|
+
}
|
|
8619
|
+
return wrapped;
|
|
8620
|
+
}
|
|
8593
8621
|
function failureElement(failure, component, reset) {
|
|
8594
8622
|
if (failure.status === "error") {
|
|
8595
8623
|
return createElement5(component ?? DefaultErrorFallback, {
|
|
@@ -8614,9 +8642,10 @@ function resolveRouteElement(input) {
|
|
|
8614
8642
|
inherited = { ...inherited, ...match.loaderData };
|
|
8615
8643
|
props.push({ ...inherited, ...context });
|
|
8616
8644
|
}
|
|
8645
|
+
const { pending } = input;
|
|
8617
8646
|
const index = matches.findIndex((match) => match.status !== "success");
|
|
8618
8647
|
const failure = matches[index];
|
|
8619
|
-
if (failure && failure.status !== "success") {
|
|
8648
|
+
if (failure && failure.status !== "success" && !pending) {
|
|
8620
8649
|
const { component, depth } = selectRouteBoundary(boundaries, input.rootBoundary, index, failure.status);
|
|
8621
8650
|
let element = failureElement(failure, component, input.reset);
|
|
8622
8651
|
for (let layout = depth;layout >= 0; layout -= 1) {
|
|
@@ -8628,18 +8657,10 @@ function resolveRouteElement(input) {
|
|
|
8628
8657
|
throw new Error("[furin] internal invariant: a successful route render requires a page.");
|
|
8629
8658
|
}
|
|
8630
8659
|
const pageProps = Object.fromEntries(Object.entries(data).filter(([key]) => !key.startsWith("__furin")));
|
|
8631
|
-
|
|
8660
|
+
const element = pending ? wrapSegments(input, pending.depth, props, pageProps, createElement5(pending.component)) : wrapSegments(input, chain.length - 1, props, pageProps, createElement5(page.component, {
|
|
8632
8661
|
...pageProps,
|
|
8633
8662
|
key: pageKey(page.pattern, pageProps, chain.at(-1)?.remountDeps)
|
|
8634
|
-
});
|
|
8635
|
-
for (let layout = chain.length - 1;layout >= 0; layout -= 1) {
|
|
8636
|
-
for (const boundary of boundaries.toReversed()) {
|
|
8637
|
-
if (boundary.depth === layout) {
|
|
8638
|
-
element = wrapSegmentBoundaries(element, boundary, input.boundaryOptions);
|
|
8639
|
-
}
|
|
8640
|
-
}
|
|
8641
|
-
element = wrapLayout(chain[layout], props[layout] ?? pageProps, element);
|
|
8642
|
-
}
|
|
8663
|
+
}));
|
|
8643
8664
|
return withRouteSnapshot(element, page.pattern, pageProps);
|
|
8644
8665
|
}
|
|
8645
8666
|
|
|
@@ -8746,6 +8767,7 @@ function LinkInteractive({
|
|
|
8746
8767
|
replace,
|
|
8747
8768
|
disabled,
|
|
8748
8769
|
resetScroll,
|
|
8770
|
+
shallow,
|
|
8749
8771
|
activeProps,
|
|
8750
8772
|
inactiveProps,
|
|
8751
8773
|
onClick,
|
|
@@ -8761,6 +8783,7 @@ function LinkInteractive({
|
|
|
8761
8783
|
const anchorRef = useRef(null);
|
|
8762
8784
|
const intentTimerRef = useRef(null);
|
|
8763
8785
|
const { activeHref, logicalHref, href } = resolveLinkHref({ hash, params, search, to }, router2);
|
|
8786
|
+
const targetSearch = useMemo2(() => resolveTargetSearch(applyLinkParams(to, params), search, router2.searchRoutes), [logicalHref, router2.searchRoutes]);
|
|
8764
8787
|
const isActive = useSyncExternalStore2(store.subscribe, () => activeHref !== undefined && store.getCurrentHref() === activeHref, () => activeHref !== undefined && store.getCurrentHref() === activeHref);
|
|
8765
8788
|
const { resolvedChildren, extraProps } = resolveLinkState({ activeProps, children, inactiveProps }, isActive);
|
|
8766
8789
|
const effectivePreload = preload ?? router2.defaultPreload;
|
|
@@ -8774,9 +8797,9 @@ function LinkInteractive({
|
|
|
8774
8797
|
}
|
|
8775
8798
|
const target = shouldInterceptClick(anchor, { altKey: false, ctrlKey: false, metaKey: false, shiftKey: false }, router2.basePath, window.location.origin, window.location.pathname);
|
|
8776
8799
|
if (target !== null) {
|
|
8777
|
-
prefetch(target, { staleTime: effectiveStaleTime });
|
|
8800
|
+
prefetch(target, { search: targetSearch, staleTime: effectiveStaleTime });
|
|
8778
8801
|
}
|
|
8779
|
-
}, [prefetch, effectiveStaleTime, router2.basePath]);
|
|
8802
|
+
}, [prefetch, effectiveStaleTime, router2.basePath, targetSearch]);
|
|
8780
8803
|
useEffect2(() => {
|
|
8781
8804
|
if (effectivePreload === "render") {
|
|
8782
8805
|
triggerPrefetch();
|
|
@@ -8826,7 +8849,7 @@ function LinkInteractive({
|
|
|
8826
8849
|
window.location.assign(href);
|
|
8827
8850
|
return;
|
|
8828
8851
|
}
|
|
8829
|
-
router2.navigate(target, { replace, resetScroll:
|
|
8852
|
+
router2.navigate(target, { replace, resetScroll, search: targetSearch, shallow });
|
|
8830
8853
|
};
|
|
8831
8854
|
const handleMouseEnter = (e) => {
|
|
8832
8855
|
onMouseEnter?.(e);
|
|
@@ -8894,6 +8917,7 @@ function renderLinkElement(props, router2) {
|
|
|
8894
8917
|
preloadStaleTime: _ps,
|
|
8895
8918
|
replace: _r,
|
|
8896
8919
|
resetScroll: _rs,
|
|
8920
|
+
shallow: _sh,
|
|
8897
8921
|
onClick: _oc,
|
|
8898
8922
|
onMouseEnter: _ome,
|
|
8899
8923
|
onMouseLeave: _oml,
|
|
@@ -10548,6 +10572,7 @@ function adaptDefinedLayout(route, parent, sourcePath) {
|
|
|
10548
10572
|
notFoundComponent: route.notFoundComponent,
|
|
10549
10573
|
params: route.schemas?.params,
|
|
10550
10574
|
...parent ? { parent } : {},
|
|
10575
|
+
pending: route.pending,
|
|
10551
10576
|
query: route.schemas?.query,
|
|
10552
10577
|
requestLoader: route.requestLoader,
|
|
10553
10578
|
revalidate: route.revalidate,
|
|
@@ -10565,6 +10590,7 @@ function adaptDefinedPage(route, parent) {
|
|
|
10565
10590
|
__type: "FURIN_ROUTE",
|
|
10566
10591
|
params: route.schemas?.params,
|
|
10567
10592
|
parent,
|
|
10593
|
+
loaderDeps: route.loaderDeps,
|
|
10568
10594
|
query: route.schemas?.query,
|
|
10569
10595
|
remountDeps: route.remountDeps,
|
|
10570
10596
|
requestLoader: route.requestLoader
|
|
@@ -10575,6 +10601,7 @@ function adaptDefinedPage(route, parent) {
|
|
|
10575
10601
|
loader: route.loader,
|
|
10576
10602
|
mode: route.mode,
|
|
10577
10603
|
notFoundComponent: route.notFoundComponent,
|
|
10604
|
+
pending: route.pending,
|
|
10578
10605
|
revalidate: route.revalidate,
|
|
10579
10606
|
staticParams: route.staticParams,
|
|
10580
10607
|
tags: copyTags(route.tags)
|
|
@@ -3777,10 +3777,10 @@ class QueryStore {
|
|
|
3777
3777
|
}
|
|
3778
3778
|
}
|
|
3779
3779
|
entry.snapshot = { ...entry.snapshot, data };
|
|
3780
|
+
this.revisionValue += 1;
|
|
3780
3781
|
for (const listener of entry.listeners) {
|
|
3781
3782
|
listener();
|
|
3782
3783
|
}
|
|
3783
|
-
this.revisionValue += 1;
|
|
3784
3784
|
for (const listener of this.listeners) {
|
|
3785
3785
|
listener();
|
|
3786
3786
|
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { FC } from "react";
|
|
2
|
+
export type PendingComponent = FC;
|
|
3
|
+
/** When a navigation shows a route's pending screen (TanStack `pendingMs` / `pendingMinMs`). */
|
|
4
|
+
export interface PendingOptions {
|
|
5
|
+
/** Minimum time the screen stays once shown, so it never blinks. Default: 500. */
|
|
6
|
+
minMs?: number;
|
|
7
|
+
/** Delay before the screen shows, so fast navigations never flash it. Default: 1000. */
|
|
8
|
+
ms?: number;
|
|
9
|
+
}
|
|
10
|
+
/** A route's `.pending()` (TanStack style) or a directory's `loading.tsx` (Next.js style). */
|
|
11
|
+
export interface RoutePending extends PendingOptions {
|
|
12
|
+
component: PendingComponent;
|
|
13
|
+
}
|
|
@@ -9,6 +9,7 @@ export interface SearchRouteMetadata {
|
|
|
9
9
|
regex: RegExp;
|
|
10
10
|
searchDefaults?: SearchParamsInput;
|
|
11
11
|
}
|
|
12
|
+
export declare function deepEqual(a: unknown, b: unknown): boolean;
|
|
12
13
|
export declare function buildSearchParams(search: SearchParamsInput, defaults?: SearchParamsInput): URLSearchParams;
|
|
13
14
|
export declare function collectSearchDefaults(schema: unknown): SearchParamsInput | undefined;
|
|
14
15
|
export declare function findSearchDefaults(pathname: string, routes: readonly SearchRouteMetadata[]): SearchParamsInput | undefined;
|
package/dist/sync-client.js
CHANGED
|
@@ -602,10 +602,10 @@ class QueryStore {
|
|
|
602
602
|
}
|
|
603
603
|
}
|
|
604
604
|
entry.snapshot = { ...entry.snapshot, data };
|
|
605
|
+
this.revisionValue += 1;
|
|
605
606
|
for (const listener of entry.listeners) {
|
|
606
607
|
listener();
|
|
607
608
|
}
|
|
608
|
-
this.revisionValue += 1;
|
|
609
609
|
for (const listener of this.listeners) {
|
|
610
610
|
listener();
|
|
611
611
|
}
|
package/package.json
CHANGED
|
@@ -152,6 +152,9 @@ export async function createBuildFingerprint(
|
|
|
152
152
|
if (segment.notFoundPath) {
|
|
153
153
|
fingerprintPaths.add(segment.notFoundPath);
|
|
154
154
|
}
|
|
155
|
+
if (segment.pendingPath) {
|
|
156
|
+
fingerprintPaths.add(segment.pendingPath);
|
|
157
|
+
}
|
|
155
158
|
}
|
|
156
159
|
}
|
|
157
160
|
const sources = new Map<string, string>();
|
|
@@ -285,6 +288,7 @@ export function buildCompileMetadata(root: BuildRoot | RootLayout, routes: Build
|
|
|
285
288
|
...(boundary.fromRoute ? { fromRoute: boundary.fromRoute } : {}),
|
|
286
289
|
notFoundPath: boundary.notFoundPath ? toPosixPath(boundary.notFoundPath) : undefined,
|
|
287
290
|
path: toPosixPath(boundary.path),
|
|
291
|
+
pendingPath: boundary.pendingPath ? toPosixPath(boundary.pendingPath) : undefined,
|
|
288
292
|
})),
|
|
289
293
|
};
|
|
290
294
|
}
|
package/src/build/hydrate.ts
CHANGED
|
@@ -118,7 +118,8 @@ function hydrateEntry(
|
|
|
118
118
|
for (const seg of route.segmentBoundaries ?? []) {
|
|
119
119
|
const errorIdent = getBoundaryIdent(boundaryIdents, seg.errorPath);
|
|
120
120
|
const notFoundIdent = getBoundaryIdent(boundaryIdents, seg.notFoundPath);
|
|
121
|
-
|
|
121
|
+
const pendingIdent = getBoundaryIdent(boundaryIdents, seg.pendingPath);
|
|
122
|
+
if (!(errorIdent || notFoundIdent || pendingIdent)) {
|
|
122
123
|
continue;
|
|
123
124
|
}
|
|
124
125
|
const parts = [`depth: ${seg.depth}`];
|
|
@@ -131,6 +132,14 @@ function hydrateEntry(
|
|
|
131
132
|
if (notFoundIdent) {
|
|
132
133
|
parts.push(`notFound: ${notFoundIdent}.${notFoundExport}`);
|
|
133
134
|
}
|
|
135
|
+
// `.pending()` stores its options with it; `loading.tsx` exports them by name.
|
|
136
|
+
if (pendingIdent) {
|
|
137
|
+
parts.push(
|
|
138
|
+
seg.fromRoute
|
|
139
|
+
? `pending: ${pendingIdent}.route.pending`
|
|
140
|
+
: `pending: { component: ${pendingIdent}.default, minMs: ${pendingIdent}.pendingMinMs, ms: ${pendingIdent}.pendingMs }`
|
|
141
|
+
);
|
|
142
|
+
}
|
|
134
143
|
if (seg.depth === 0 && seg.path.replaceAll("\\", "/") !== rootDirectory) {
|
|
135
144
|
parts.push("isRoot: false");
|
|
136
145
|
}
|
|
@@ -157,7 +166,7 @@ function hydrateEntry(
|
|
|
157
166
|
? `, segmentBoundaries: [${boundaryLiterals.join(", ")}]`
|
|
158
167
|
: "";
|
|
159
168
|
const pageComponentKey = JSON.stringify(`page:${modulePathKey(resolvedPage)}`);
|
|
160
|
-
const loadBody = `Promise.all([${lazyImports.join(", ")}]).then(([${importIdents.join(", ")}]) => { const __furin_page_route = __furin_page.route; let __furin_parent = root; ${layoutAssignments} return { default: { __type: "FURIN_PAGE", _route: { __type: "FURIN_ROUTE", parent: __furin_parent, remountDeps: __furin_page_route.remountDeps }, component: hotComponent(${pageComponentKey}, __furin_page_route.component) }${boundaryResult} }; })`;
|
|
169
|
+
const loadBody = `Promise.all([${lazyImports.join(", ")}]).then(([${importIdents.join(", ")}]) => { const __furin_page_route = __furin_page.route; let __furin_parent = root; ${layoutAssignments} return { default: { __type: "FURIN_PAGE", _route: { __type: "FURIN_ROUTE", parent: __furin_parent, loaderDeps: __furin_page_route.loaderDeps, remountDeps: __furin_page_route.remountDeps }, component: hotComponent(${pageComponentKey}, __furin_page_route.component) }${boundaryResult} }; })`;
|
|
161
170
|
|
|
162
171
|
const searchDefaultsEntry = searchDefaults
|
|
163
172
|
? `, searchDefaults: ${JSON.stringify(searchDefaults)}`
|
|
@@ -20,7 +20,9 @@ function routeModulePaths(route: BuildRouteInput): string[] {
|
|
|
20
20
|
.filter((entry) => entry.layout && entry.sourcePath)
|
|
21
21
|
.map((entry) => entry.sourcePath as string);
|
|
22
22
|
const boundaries = (route.segmentBoundaries ?? []).flatMap((segment) =>
|
|
23
|
-
[segment.errorPath, segment.notFoundPath].filter(
|
|
23
|
+
[segment.errorPath, segment.notFoundPath, segment.pendingPath].filter(
|
|
24
|
+
(path) => path !== undefined
|
|
25
|
+
)
|
|
24
26
|
);
|
|
25
27
|
return [route.path, ...layouts, ...boundaries];
|
|
26
28
|
}
|
|
@@ -31,7 +31,7 @@ export interface BuildRoute
|
|
|
31
31
|
routeChain: { layout: boolean; sourcePath?: string }[];
|
|
32
32
|
segmentBoundaries: Pick<
|
|
33
33
|
SegmentBoundary,
|
|
34
|
-
"depth" | "path" | "errorPath" | "fromRoute" | "notFoundPath"
|
|
34
|
+
"depth" | "path" | "errorPath" | "fromRoute" | "notFoundPath" | "pendingPath"
|
|
35
35
|
>[];
|
|
36
36
|
}
|
|
37
37
|
|
|
@@ -84,12 +84,13 @@ export function buildRouteMetadata(route: ResolvedRoute): BuildRoute {
|
|
|
84
84
|
sourcePath: entry.sourcePath,
|
|
85
85
|
})),
|
|
86
86
|
segmentBoundaries: route.segmentBoundaries.map(
|
|
87
|
-
({ depth, path, errorPath, fromRoute, notFoundPath }) => ({
|
|
87
|
+
({ depth, path, errorPath, fromRoute, notFoundPath, pendingPath }) => ({
|
|
88
88
|
depth,
|
|
89
89
|
path,
|
|
90
90
|
errorPath,
|
|
91
91
|
...(fromRoute ? { fromRoute } : {}),
|
|
92
92
|
notFoundPath,
|
|
93
|
+
pendingPath,
|
|
93
94
|
})
|
|
94
95
|
),
|
|
95
96
|
tags: route.tags,
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { ErrorComponent } from "../shared/error.ts";
|
|
2
2
|
import type { NotFoundComponent } from "../shared/not-found.ts";
|
|
3
3
|
import type { RemountDeps } from "../shared/page-key.ts";
|
|
4
|
+
import type { PendingComponent, PendingOptions, RoutePending } from "../shared/pending.ts";
|
|
4
5
|
|
|
5
6
|
type ClientComponent = (props: never) => React.ReactNode;
|
|
6
7
|
|
|
@@ -14,17 +15,25 @@ interface ClientRuntimeProps {
|
|
|
14
15
|
|
|
15
16
|
type ClientRuntimeComponent = (props: ClientRuntimeProps) => React.ReactNode;
|
|
16
17
|
|
|
18
|
+
type LoaderDeps = (query: never) => object;
|
|
19
|
+
|
|
17
20
|
interface ClientBuilderState {
|
|
18
21
|
errorComponent: ErrorComponent | undefined;
|
|
22
|
+
loaderDeps: LoaderDeps | undefined;
|
|
19
23
|
notFoundComponent: NotFoundComponent | undefined;
|
|
24
|
+
pending: RoutePending | undefined;
|
|
20
25
|
remountDeps: RemountDeps<never, never> | undefined;
|
|
21
26
|
}
|
|
22
27
|
|
|
23
28
|
function createRouteBuilder(state: ClientBuilderState) {
|
|
24
|
-
const { errorComponent, notFoundComponent, remountDeps } = state;
|
|
29
|
+
const { errorComponent, loaderDeps, notFoundComponent, pending, remountDeps } = state;
|
|
25
30
|
return {
|
|
26
|
-
config(options: { remountDeps?: RemountDeps<never, never> }) {
|
|
27
|
-
return createRouteBuilder({
|
|
31
|
+
config(options: { loaderDeps?: LoaderDeps; remountDeps?: RemountDeps<never, never> }) {
|
|
32
|
+
return createRouteBuilder({
|
|
33
|
+
...state,
|
|
34
|
+
loaderDeps: options.loaderDeps,
|
|
35
|
+
remountDeps: options.remountDeps,
|
|
36
|
+
});
|
|
28
37
|
},
|
|
29
38
|
error(component: ErrorComponent) {
|
|
30
39
|
return createRouteBuilder({ ...state, errorComponent: component });
|
|
@@ -37,19 +46,28 @@ function createRouteBuilder(state: ClientBuilderState) {
|
|
|
37
46
|
errorComponent,
|
|
38
47
|
layout: runtimeComponent,
|
|
39
48
|
notFoundComponent,
|
|
49
|
+
pending,
|
|
40
50
|
};
|
|
41
51
|
},
|
|
42
52
|
notFound(component: NotFoundComponent) {
|
|
43
53
|
return createRouteBuilder({ ...state, notFoundComponent: component });
|
|
44
54
|
},
|
|
55
|
+
pending(component: PendingComponent, options?: PendingOptions) {
|
|
56
|
+
return createRouteBuilder({
|
|
57
|
+
...state,
|
|
58
|
+
pending: { component, minMs: options?.minMs, ms: options?.ms },
|
|
59
|
+
});
|
|
60
|
+
},
|
|
45
61
|
page<Component extends ClientComponent>(component: Component) {
|
|
46
62
|
const runtimeComponent = component as unknown as ClientRuntimeComponent;
|
|
47
63
|
return {
|
|
48
64
|
__type: "FURIN_ROUTE" as const,
|
|
49
65
|
component: runtimeComponent,
|
|
50
66
|
errorComponent,
|
|
67
|
+
loaderDeps,
|
|
51
68
|
notFoundComponent,
|
|
52
69
|
page: runtimeComponent,
|
|
70
|
+
pending,
|
|
53
71
|
remountDeps,
|
|
54
72
|
};
|
|
55
73
|
},
|
|
@@ -58,7 +76,9 @@ function createRouteBuilder(state: ClientBuilderState) {
|
|
|
58
76
|
|
|
59
77
|
const EMPTY_BUILDER: ClientBuilderState = {
|
|
60
78
|
errorComponent: undefined,
|
|
79
|
+
loaderDeps: undefined,
|
|
61
80
|
notFoundComponent: undefined,
|
|
81
|
+
pending: undefined,
|
|
62
82
|
remountDeps: undefined,
|
|
63
83
|
};
|
|
64
84
|
|