@teyik0/furin 0.9.0-alpha.4 → 0.9.0-alpha.6

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 (63) hide show
  1. package/dist/adapter/runtime-build.d.ts +1 -0
  2. package/dist/adapter/vercel.js +9 -6
  3. package/dist/build/index.js +74 -31
  4. package/dist/build/route-metadata.d.ts +1 -1
  5. package/dist/cli/index.js +74 -31
  6. package/dist/client/chunks/{client-rdxyrw11.js → client-hjqd5m3b.js} +1 -1
  7. package/dist/client/chunks/{client-p0jqzfvc.js → client-whph3y67.js} +1 -1
  8. package/dist/client/chunks/{client-a7spxfnn.js → client-xf7r768c.js} +13 -1
  9. package/dist/client/define-route.d.ts +12 -0
  10. package/dist/client/internal/runtime-types.d.ts +7 -0
  11. package/dist/client/link.js +200 -40
  12. package/dist/client/route-element.d.ts +5 -0
  13. package/dist/client/router/history.d.ts +6 -0
  14. package/dist/client/router/link-utils.d.ts +7 -0
  15. package/dist/client/router/navigation-controller.d.ts +20 -2
  16. package/dist/client/router/pending.d.ts +17 -0
  17. package/dist/client/router/search/index.d.ts +2 -0
  18. package/dist/client/router/search/index.js +7 -3
  19. package/dist/client/router/types.d.ts +21 -1
  20. package/dist/client.js +19 -4
  21. package/dist/define-route.d.ts +37 -10
  22. package/dist/furin.js +88 -29
  23. package/dist/plugin/client-plugin.d.ts +1 -1
  24. package/dist/plugin/index.js +36 -17
  25. package/dist/plugin/route-manifest.d.ts +2 -1
  26. package/dist/plugin/strip-server-stages.d.ts +1 -1
  27. package/dist/server/internal.d.ts +1 -0
  28. package/dist/server/internal.js +42 -15
  29. package/dist/server/router/defined-route.d.ts +3 -0
  30. package/dist/server/router/types.d.ts +7 -1
  31. package/dist/server/static-export.js +45 -15
  32. package/dist/shared/pending.d.ts +13 -0
  33. package/dist/shared/search-params.d.ts +1 -0
  34. package/package.json +1 -1
  35. package/src/adapter/runtime-build.ts +4 -0
  36. package/src/adapter/vercel.ts +21 -8
  37. package/src/build/hydrate.ts +11 -2
  38. package/src/build/preload-manifest.ts +3 -1
  39. package/src/build/route-metadata.ts +3 -2
  40. package/src/client/define-route.ts +23 -3
  41. package/src/client/internal/runtime-types.ts +7 -0
  42. package/src/client/link.tsx +26 -4
  43. package/src/client/route-element.tsx +41 -15
  44. package/src/client/router/context.ts +29 -8
  45. package/src/client/router/history.ts +10 -0
  46. package/src/client/router/link-utils.ts +23 -0
  47. package/src/client/router/navigation-controller.ts +239 -19
  48. package/src/client/router/pending.ts +58 -0
  49. package/src/client/router/provider.tsx +5 -2
  50. package/src/client/router/search/index.ts +7 -2
  51. package/src/client/router/types.ts +29 -3
  52. package/src/define-route.ts +74 -26
  53. package/src/plugin/client-plugin.ts +5 -4
  54. package/src/plugin/route-config.ts +9 -2
  55. package/src/plugin/route-manifest.ts +11 -3
  56. package/src/plugin/route-tree.ts +2 -2
  57. package/src/plugin/strip-server-stages.ts +60 -35
  58. package/src/server/internal.ts +1 -0
  59. package/src/server/router/defined-route.ts +6 -0
  60. package/src/server/router/discovery.ts +5 -2
  61. package/src/server/router/types.ts +7 -1
  62. package/src/shared/pending.ts +16 -0
  63. package/src/shared/search-params.ts +1 -1
package/dist/furin.js CHANGED
@@ -717,6 +717,7 @@ function terminalFields(runtime) {
717
717
  metadata,
718
718
  notFoundComponent,
719
719
  paramsSchema,
720
+ pending,
720
721
  querySchema,
721
722
  requestLoader
722
723
  } = runtime;
@@ -724,8 +725,10 @@ function terminalFields(runtime) {
724
725
  __type: "FURIN_ROUTE",
725
726
  errorComponent,
726
727
  notFoundComponent,
728
+ pending,
727
729
  mode: metadata.mode,
728
730
  revalidate: metadata.revalidate,
731
+ loaderDeps: metadata.loaderDeps,
729
732
  remountDeps: metadata.remountDeps,
730
733
  staticParams: metadata.staticParams,
731
734
  tags: metadata.tags,
@@ -747,6 +750,12 @@ class RouteChain {
747
750
  notFound(component) {
748
751
  return new RouteChain({ ...this.runtime, notFoundComponent: component });
749
752
  }
753
+ pending(component, options) {
754
+ return new RouteChain({
755
+ ...this.runtime,
756
+ pending: { component, minMs: options?.minMs, ms: options?.ms }
757
+ });
758
+ }
750
759
  requestLoader(requestLoader) {
751
760
  return new RouteChain({
752
761
  ...this.runtime,
@@ -800,6 +809,7 @@ function configure(options) {
800
809
  metadata: options,
801
810
  notFoundComponent: undefined,
802
811
  paramsSchema: options.params,
812
+ pending: undefined,
803
813
  querySchema: options.query,
804
814
  requestLoader: undefined
805
815
  });
@@ -4902,6 +4912,18 @@ function applyLinkParams(to, params) {
4902
4912
  }
4903
4913
  return url;
4904
4914
  }
4915
+ function resolveTargetSearch(path, search, routes) {
4916
+ if (path.includes("?")) {
4917
+ return;
4918
+ }
4919
+ const resolved = { ...findSearchDefaultsForRouteTarget(path, routes) };
4920
+ for (const [key, value] of Object.entries(search ?? {})) {
4921
+ if (value !== null && value !== undefined) {
4922
+ resolved[key] = value;
4923
+ }
4924
+ }
4925
+ return resolved;
4926
+ }
4905
4927
  function buildHref(to, search, hash, searchDefaults) {
4906
4928
  let url = to;
4907
4929
  if (search && Object.keys(search).length > 0) {
@@ -10508,7 +10530,14 @@ var init_search_store = __esm(() => {
10508
10530
  var init_router = () => {};
10509
10531
 
10510
10532
  // src/client/link.tsx
10511
- import { createElement as createElement4, useCallback as useCallback3, useEffect as useEffect2, useRef, useSyncExternalStore as useSyncExternalStore2 } from "react";
10533
+ import {
10534
+ createElement as createElement4,
10535
+ useCallback as useCallback3,
10536
+ useEffect as useEffect2,
10537
+ useMemo as useMemo2,
10538
+ useRef,
10539
+ useSyncExternalStore as useSyncExternalStore2
10540
+ } from "react";
10512
10541
  import { jsxDEV as jsxDEV2 } from "react/jsx-dev-runtime";
10513
10542
  function resolveLinkHref({ to, params, search, hash }, router2) {
10514
10543
  const resolvedTo = applyLinkParams(to, params);
@@ -10547,6 +10576,7 @@ function LinkInteractive({
10547
10576
  replace,
10548
10577
  disabled,
10549
10578
  resetScroll,
10579
+ shallow,
10550
10580
  activeProps,
10551
10581
  inactiveProps,
10552
10582
  onClick,
@@ -10562,6 +10592,7 @@ function LinkInteractive({
10562
10592
  const anchorRef = useRef(null);
10563
10593
  const intentTimerRef = useRef(null);
10564
10594
  const { activeHref, logicalHref, href } = resolveLinkHref({ hash, params, search, to }, router2);
10595
+ const targetSearch = useMemo2(() => resolveTargetSearch(applyLinkParams(to, params), search, router2.searchRoutes), [logicalHref, router2.searchRoutes]);
10565
10596
  const isActive = useSyncExternalStore2(store.subscribe, () => activeHref !== undefined && store.getCurrentHref() === activeHref, () => activeHref !== undefined && store.getCurrentHref() === activeHref);
10566
10597
  const { resolvedChildren, extraProps } = resolveLinkState({ activeProps, children, inactiveProps }, isActive);
10567
10598
  const effectivePreload = preload ?? router2.defaultPreload;
@@ -10575,9 +10606,9 @@ function LinkInteractive({
10575
10606
  }
10576
10607
  const target = shouldInterceptClick(anchor, { altKey: false, ctrlKey: false, metaKey: false, shiftKey: false }, router2.basePath, window.location.origin, window.location.pathname);
10577
10608
  if (target !== null) {
10578
- prefetch(target, { staleTime: effectiveStaleTime });
10609
+ prefetch(target, { search: targetSearch, staleTime: effectiveStaleTime });
10579
10610
  }
10580
- }, [prefetch, effectiveStaleTime, router2.basePath]);
10611
+ }, [prefetch, effectiveStaleTime, router2.basePath, targetSearch]);
10581
10612
  useEffect2(() => {
10582
10613
  if (effectivePreload === "render") {
10583
10614
  triggerPrefetch();
@@ -10627,7 +10658,7 @@ function LinkInteractive({
10627
10658
  window.location.assign(href);
10628
10659
  return;
10629
10660
  }
10630
- router2.navigate(target, { replace, resetScroll: resetScroll ?? true });
10661
+ router2.navigate(target, { replace, resetScroll, search: targetSearch, shallow });
10631
10662
  };
10632
10663
  const handleMouseEnter = (e) => {
10633
10664
  onMouseEnter?.(e);
@@ -10681,6 +10712,7 @@ function renderLinkElement(props, router2) {
10681
10712
  preloadStaleTime: _ps,
10682
10713
  replace: _r,
10683
10714
  resetScroll: _rs,
10715
+ shallow: _sh,
10684
10716
  onClick: _oc,
10685
10717
  onMouseEnter: _ome,
10686
10718
  onMouseLeave: _oml,
@@ -11170,6 +11202,18 @@ function selectRouteBoundary(boundaries, rootBoundary, index, kind) {
11170
11202
  function wrapLayout(route, props, element) {
11171
11203
  return route?.layout ? createElement6(route.layout, props, element) : element;
11172
11204
  }
11205
+ function wrapSegments(input, depth, props, fallbackProps, element) {
11206
+ let wrapped = element;
11207
+ for (let layout = depth;layout >= 0; layout -= 1) {
11208
+ for (const boundary of input.boundaries.toReversed()) {
11209
+ if (boundary.depth === layout) {
11210
+ wrapped = wrapSegmentBoundaries(wrapped, boundary, input.boundaryOptions);
11211
+ }
11212
+ }
11213
+ wrapped = wrapLayout(input.chain[layout], props[layout] ?? fallbackProps, wrapped);
11214
+ }
11215
+ return wrapped;
11216
+ }
11173
11217
  function failureElement(failure, component, reset) {
11174
11218
  if (failure.status === "error") {
11175
11219
  return createElement6(component ?? DefaultErrorFallback, {
@@ -11194,9 +11238,10 @@ function resolveRouteElement(input) {
11194
11238
  inherited = { ...inherited, ...match.loaderData };
11195
11239
  props.push({ ...inherited, ...context });
11196
11240
  }
11241
+ const { pending } = input;
11197
11242
  const index = matches.findIndex((match) => match.status !== "success");
11198
11243
  const failure = matches[index];
11199
- if (failure && failure.status !== "success") {
11244
+ if (failure && failure.status !== "success" && !pending) {
11200
11245
  const { component, depth } = selectRouteBoundary(boundaries, input.rootBoundary, index, failure.status);
11201
11246
  let element = failureElement(failure, component, input.reset);
11202
11247
  for (let layout = depth;layout >= 0; layout -= 1) {
@@ -11208,18 +11253,10 @@ function resolveRouteElement(input) {
11208
11253
  throw new Error("[furin] internal invariant: a successful route render requires a page.");
11209
11254
  }
11210
11255
  const pageProps = Object.fromEntries(Object.entries(data).filter(([key]) => !key.startsWith("__furin")));
11211
- let element = createElement6(page.component, {
11256
+ const element = pending ? wrapSegments(input, pending.depth, props, pageProps, createElement6(pending.component)) : wrapSegments(input, chain.length - 1, props, pageProps, createElement6(page.component, {
11212
11257
  ...pageProps,
11213
11258
  key: pageKey(page.pattern, pageProps, chain.at(-1)?.remountDeps)
11214
- });
11215
- for (let layout = chain.length - 1;layout >= 0; layout -= 1) {
11216
- for (const boundary of boundaries.toReversed()) {
11217
- if (boundary.depth === layout) {
11218
- element = wrapSegmentBoundaries(element, boundary, input.boundaryOptions);
11219
- }
11220
- }
11221
- element = wrapLayout(chain[layout], props[layout] ?? pageProps, element);
11222
- }
11259
+ }));
11223
11260
  return withRouteSnapshot(element, page.pattern, pageProps);
11224
11261
  }
11225
11262
  var init_route_element = __esm(() => {
@@ -15242,6 +15279,8 @@ function addNextFile(state, base, segments, sourcePath) {
15242
15279
  state.boundary.errorPath ??= sourcePath;
15243
15280
  } else if (base === "not-found") {
15244
15281
  state.boundary.notFoundPath ??= sourcePath;
15282
+ } else if (base === "loading") {
15283
+ state.boundary.pendingPath ??= sourcePath;
15245
15284
  }
15246
15285
  }
15247
15286
  function scanNext(pagesDir) {
@@ -15249,7 +15288,12 @@ function scanNext(pagesDir) {
15249
15288
  const boundaries = [];
15250
15289
  let rootPath;
15251
15290
  const walk = (directory, segments) => {
15252
- const boundary = { directory, errorPath: undefined, notFoundPath: undefined };
15291
+ const boundary = {
15292
+ directory,
15293
+ errorPath: undefined,
15294
+ notFoundPath: undefined,
15295
+ pendingPath: undefined
15296
+ };
15253
15297
  const state = { boundary, candidates, rootPath };
15254
15298
  for (const entry of sortedEntries(directory)) {
15255
15299
  const sourcePath = child(directory, entry.name);
@@ -15260,7 +15304,7 @@ function scanNext(pagesDir) {
15260
15304
  }
15261
15305
  }
15262
15306
  rootPath ??= state.rootPath;
15263
- if (boundary.errorPath || boundary.notFoundPath) {
15307
+ if (boundary.errorPath || boundary.notFoundPath || boundary.pendingPath) {
15264
15308
  boundaries.push(boundary);
15265
15309
  }
15266
15310
  };
@@ -15395,6 +15439,7 @@ function adaptDefinedLayout(route, parent, sourcePath) {
15395
15439
  notFoundComponent: route.notFoundComponent,
15396
15440
  params: route.schemas?.params,
15397
15441
  ...parent ? { parent } : {},
15442
+ pending: route.pending,
15398
15443
  query: route.schemas?.query,
15399
15444
  requestLoader: route.requestLoader,
15400
15445
  revalidate: route.revalidate,
@@ -15412,6 +15457,7 @@ function adaptDefinedPage(route, parent) {
15412
15457
  __type: "FURIN_ROUTE",
15413
15458
  params: route.schemas?.params,
15414
15459
  parent,
15460
+ loaderDeps: route.loaderDeps,
15415
15461
  query: route.schemas?.query,
15416
15462
  remountDeps: route.remountDeps,
15417
15463
  requestLoader: route.requestLoader
@@ -15422,6 +15468,7 @@ function adaptDefinedPage(route, parent) {
15422
15468
  loader: route.loader,
15423
15469
  mode: route.mode,
15424
15470
  notFoundComponent: route.notFoundComponent,
15471
+ pending: route.pending,
15425
15472
  revalidate: route.revalidate,
15426
15473
  staticParams: route.staticParams,
15427
15474
  tags: copyTags(route.tags)
@@ -15661,8 +15708,8 @@ function routeDefinedBoundaries(root, routeChain, page, pagePath) {
15661
15708
  ];
15662
15709
  const pagesDir = root.path.slice(0, root.path.lastIndexOf("/"));
15663
15710
  return entries.flatMap(({ depth, path, route }) => {
15664
- const { errorComponent, notFoundComponent } = route;
15665
- if (path === undefined || !(errorComponent || notFoundComponent)) {
15711
+ const { errorComponent, notFoundComponent, pending } = route;
15712
+ if (path === undefined || !(errorComponent || notFoundComponent || pending)) {
15666
15713
  return [];
15667
15714
  }
15668
15715
  return [
@@ -15673,7 +15720,8 @@ function routeDefinedBoundaries(root, routeChain, page, pagePath) {
15673
15720
  fromRoute: true,
15674
15721
  notFound: notFoundComponent,
15675
15722
  notFoundPath: notFoundComponent ? path : undefined,
15676
- path: path === root.path ? pagesDir : path
15723
+ path: path === root.path ? pagesDir : path,
15724
+ pendingPath: pending ? path : undefined
15677
15725
  }
15678
15726
  ];
15679
15727
  });
@@ -15729,7 +15777,8 @@ async function collectSegmentBoundaries(pageAbsolutePath, boundaries, cache) {
15729
15777
  errorPath: errorEntry?.path,
15730
15778
  notFound: notFoundEntry?.component,
15731
15779
  notFoundPath: notFoundEntry?.path,
15732
- path: boundary.directory
15780
+ path: boundary.directory,
15781
+ pendingPath: boundary.pendingPath
15733
15782
  }));
15734
15783
  cache.set(boundary.directory, loaded);
15735
15784
  return loaded;
@@ -21740,7 +21789,7 @@ function routeSnapshotSourcePaths(instance) {
21740
21789
  return [
21741
21790
  ...existsSync9(rootPath) ? [rootPath] : [],
21742
21791
  ...routes.map(({ sourcePath }) => sourcePath),
21743
- ...boundaries.flatMap(({ errorPath, notFoundPath }) => [errorPath, notFoundPath].filter((path) => path !== undefined))
21792
+ ...boundaries.flatMap(({ errorPath, notFoundPath, pendingPath }) => [errorPath, notFoundPath, pendingPath].filter((path) => path !== undefined))
21744
21793
  ].map((path) => resolve8(path)).toSorted((left, right) => left.localeCompare(right));
21745
21794
  }
21746
21795
  var init_route_tree = __esm(() => {
@@ -22277,11 +22326,11 @@ function checkParams(file, route, parsed) {
22277
22326
  ${paramsSchema(missing)}`);
22278
22327
  }
22279
22328
  function checkBoundaryMethods(file, instance, parsed) {
22280
- const method = ["error", "notFound"].find((name) => parsed.route.methods.has(name));
22329
+ const method = BOUNDARY_METHODS.find((name) => parsed.route.methods.has(name));
22281
22330
  if (instance.style !== "nextjs" || method === undefined) {
22282
22331
  return;
22283
22332
  }
22284
- const convention = method === "error" ? "an error.tsx" : "a not-found.tsx";
22333
+ const convention = BOUNDARY_CONVENTIONS[method];
22285
22334
  return issueAt(file, parsed, parsed.route.head, `.${method}() is the TanStack style. In the nextjs style, default-export the component from ${convention} next to this route.`);
22286
22335
  }
22287
22336
  function checkRoute(file, instance, route, parsed) {
@@ -22373,7 +22422,7 @@ function scaffoldEmptyRoutes(spec) {
22373
22422
  }
22374
22423
  return written;
22375
22424
  }
22376
- var IDENTIFIER_RE, ROUTE_CONFIG_DIAGNOSTIC = "route config", ROOT_TEMPLATE = `import { defineRootRoute, HeadContent, Scripts } from "@teyik0/furin";
22425
+ var IDENTIFIER_RE, BOUNDARY_CONVENTIONS, BOUNDARY_METHODS, ROUTE_CONFIG_DIAGNOSTIC = "route config", ROOT_TEMPLATE = `import { defineRootRoute, HeadContent, Scripts } from "@teyik0/furin";
22377
22426
 
22378
22427
  export const route = defineRootRoute()
22379
22428
  .config({ mode: "ssr" })
@@ -22395,6 +22444,12 @@ var init_route_config = __esm(() => {
22395
22444
  init_route_chains();
22396
22445
  init_route_manifest();
22397
22446
  IDENTIFIER_RE = /^[A-Za-z_$][\w$]*$/;
22447
+ BOUNDARY_CONVENTIONS = {
22448
+ error: "an error.tsx",
22449
+ notFound: "a not-found.tsx",
22450
+ pending: "a loading.tsx"
22451
+ };
22452
+ BOUNDARY_METHODS = ["error", "notFound", "pending"];
22398
22453
  });
22399
22454
 
22400
22455
  // src/build/route-metadata.ts
@@ -22603,7 +22658,8 @@ function hydrateEntry(routes, rootLayout, basePath, clientLogging, modulePathKey
22603
22658
  for (const seg of route.segmentBoundaries ?? []) {
22604
22659
  const errorIdent = getBoundaryIdent(boundaryIdents, seg.errorPath);
22605
22660
  const notFoundIdent = getBoundaryIdent(boundaryIdents, seg.notFoundPath);
22606
- if (!(errorIdent || notFoundIdent)) {
22661
+ const pendingIdent = getBoundaryIdent(boundaryIdents, seg.pendingPath);
22662
+ if (!(errorIdent || notFoundIdent || pendingIdent)) {
22607
22663
  continue;
22608
22664
  }
22609
22665
  const parts = [`depth: ${seg.depth}`];
@@ -22615,6 +22671,9 @@ function hydrateEntry(routes, rootLayout, basePath, clientLogging, modulePathKey
22615
22671
  if (notFoundIdent) {
22616
22672
  parts.push(`notFound: ${notFoundIdent}.${notFoundExport}`);
22617
22673
  }
22674
+ if (pendingIdent) {
22675
+ parts.push(seg.fromRoute ? `pending: ${pendingIdent}.route.pending` : `pending: { component: ${pendingIdent}.default, minMs: ${pendingIdent}.pendingMinMs, ms: ${pendingIdent}.pendingMs }`);
22676
+ }
22618
22677
  if (seg.depth === 0 && seg.path.replaceAll("\\", "/") !== rootDirectory) {
22619
22678
  parts.push("isRoot: false");
22620
22679
  }
@@ -22633,7 +22692,7 @@ function hydrateEntry(routes, rootLayout, basePath, clientLogging, modulePathKey
22633
22692
  }).join(" ");
22634
22693
  const boundaryResult = boundaryLiterals.length > 0 ? `, segmentBoundaries: [${boundaryLiterals.join(", ")}]` : "";
22635
22694
  const pageComponentKey = JSON.stringify(`page:${modulePathKey(resolvedPage)}`);
22636
- 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} }; })`;
22695
+ 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} }; })`;
22637
22696
  const searchDefaultsEntry = searchDefaults ? `, searchDefaults: ${JSON.stringify(searchDefaults)}` : "";
22638
22697
  routeEntries.push(` { pattern: ${JSON.stringify(route.pattern)}, regex: new RegExp(${JSON.stringify(regexPattern)}), load: () => ${loadBody}${searchDefaultsEntry} }`);
22639
22698
  }
@@ -25522,7 +25581,7 @@ function createLocalSyncClient(options) {
25522
25581
  var furinSync2 = furinSync;
25523
25582
  var invalidateSync2 = invalidateSync;
25524
25583
  // src/shared/await.tsx
25525
- import { Component as Component2, createContext as createContext8, createElement as createElement11, use as use3, useMemo as useMemo2 } from "react";
25584
+ import { Component as Component2, createContext as createContext8, createElement as createElement11, use as use3, useMemo as useMemo3 } from "react";
25526
25585
  var AsyncErrorContext = createContext8(undefined);
25527
25586
  function useAsyncError() {
25528
25587
  return use3(AsyncErrorContext);
@@ -25574,7 +25633,7 @@ class AsyncErrorBoundary extends Component2 {
25574
25633
  }
25575
25634
  }
25576
25635
  function Await({ resolve, errorElement, children }) {
25577
- const guardedResolve = useMemo2(() => silenceAbortError(resolve), [resolve]);
25636
+ const guardedResolve = useMemo3(() => silenceAbortError(resolve), [resolve]);
25578
25637
  return createElement11(AsyncErrorBoundary, { errorElement, resolve: guardedResolve }, createElement11(AwaitInner, { children, resolve: guardedResolve }));
25579
25638
  }
25580
25639
  function AwaitInner({ resolve, children }) {
@@ -9,7 +9,7 @@ interface ClientStripPluginOptions {
9
9
  /**
10
10
  * Furin's browser-graph plugin, shared by the dev server (bunfig
11
11
  * `[serve.static] plugins`) and the production client build:
12
- * 1. Stubs `elysia` for the browser with its schema builder only.
12
+ * 1. Stubs `elysia` for the browser with its schema builder and errors only.
13
13
  * 2. Stubs `bun:*` builtins with an empty module (safety net — DCE removes
14
14
  * loader imports before they reach the browser bundle in practice).
15
15
  * 3. Strips server-only code (loader, query, params) from page files before
@@ -3687,14 +3687,16 @@ function memberAccessStart(source, object, property) {
3687
3687
  const separator = accessGap.replace(/\/\*[\s\S]*?\*\/|\/\/[^\r\n]*/g, (comment) => " ".repeat(comment.length)).lastIndexOf(".");
3688
3688
  return object.end + separator - (accessGap[separator - 1] === "?" ? 1 : 0);
3689
3689
  }
3690
- function stripServerStage(module, stripped, range, remount) {
3690
+ function stripServerStage(module, stripped, range, policies) {
3691
3691
  const { removed, source } = module;
3692
- if (remount) {
3693
- const policy = source.slice(remount.start, remount.end);
3694
- for (const name of referencedNames(remount, removed)) {
3695
- stripped.retained.add(name);
3692
+ if (policies.length > 0) {
3693
+ const retained = policies.map((policy) => source.slice(policy.start, policy.end));
3694
+ for (const policy of policies) {
3695
+ for (const name of referencedNames(policy, removed)) {
3696
+ stripped.retained.add(name);
3697
+ }
3696
3698
  }
3697
- replaceRange(module, range.start, range.end, `.config({ ${policy} })`);
3699
+ replaceRange(module, range.start, range.end, `.config({ ${retained.join(", ")} })`);
3698
3700
  } else {
3699
3701
  removeRange(module, range.start, range.end);
3700
3702
  }
@@ -3707,20 +3709,36 @@ function removeChainedServerCalls(module, bindings, chains, stripped) {
3707
3709
  if (isRemoved(call, module.removed)) {
3708
3710
  continue;
3709
3711
  }
3710
- let remount = null;
3712
+ let policies = [];
3711
3713
  if (property.name === "config" && Array.isArray(call.arguments)) {
3712
3714
  const config = unwrapped(call.arguments[0]);
3713
3715
  if (config?.type === "ObjectExpression" && Array.isArray(config.properties)) {
3714
3716
  collectConfigBindings(config, declarations, stripped.configBindings);
3715
- remount = resolveRemountProperty(config, declarations, stripped.configBindings, new Set, filename);
3717
+ policies = clientPolicies(config, declarations, stripped.configBindings, filename);
3716
3718
  }
3717
3719
  }
3718
3720
  const accessStart = memberAccessStart(source.original, object, property);
3719
- stripServerStage(module, stripped, { end: call.end, start: accessStart }, remount);
3721
+ stripServerStage(module, stripped, { end: call.end, start: accessStart }, policies);
3720
3722
  transformed = true;
3721
3723
  }
3722
3724
  return transformed;
3723
3725
  }
3726
+ function clientPolicies(config, declarations, configBindings, filename) {
3727
+ const resolve = (name) => resolveConfigProperty(config, name, declarations, configBindings, new Set);
3728
+ const loaderDeps = resolve("loaderDeps");
3729
+ const remount = resolve("remountDeps");
3730
+ if (remount === UNRESOLVED) {
3731
+ throw new Error(`[furin] ${filename}: route config spreads must resolve to local object literals; declare remountDeps after dynamic spreads.`);
3732
+ }
3733
+ const policies = [];
3734
+ if (loaderDeps !== null && loaderDeps !== UNRESOLVED) {
3735
+ policies.push(loaderDeps);
3736
+ }
3737
+ if (remount !== null) {
3738
+ policies.push(remount);
3739
+ }
3740
+ return policies;
3741
+ }
3724
3742
  function declaredInitializer(declaration) {
3725
3743
  return declaration?.type === "VariableDeclarator" ? unwrapped(declaration.init) : null;
3726
3744
  }
@@ -3738,28 +3756,29 @@ function collectConfigBindings(config, declarations, names) {
3738
3756
  }
3739
3757
  }
3740
3758
  }
3741
- function resolveRemountProperty(config, declarations, configBindings, visiting, filename) {
3759
+ var UNRESOLVED = Symbol("unresolved");
3760
+ function resolveConfigProperty(config, name, declarations, configBindings, visiting) {
3742
3761
  if (config?.type === "Identifier" && !visiting.has(config.name)) {
3743
3762
  visiting.add(config.name);
3744
3763
  configBindings.add(config.name);
3745
3764
  const declaration = declarations.get(config.name);
3746
- const result = resolveRemountProperty(declaredInitializer(declaration), declarations, configBindings, visiting, filename);
3765
+ const result = resolveConfigProperty(declaredInitializer(declaration), name, declarations, configBindings, visiting);
3747
3766
  visiting.delete(config.name);
3748
3767
  return result;
3749
3768
  }
3750
3769
  if (config?.type !== "ObjectExpression" || !Array.isArray(config.properties)) {
3751
- throw new Error(`[furin] ${filename}: route config spreads must resolve to local object literals; declare remountDeps after dynamic spreads.`);
3770
+ return UNRESOLVED;
3752
3771
  }
3753
3772
  for (let index = config.properties.length - 1;index >= 0; index -= 1) {
3754
3773
  const entry = unwrapped(config.properties[index]);
3755
3774
  if (entry?.type === "SpreadElement") {
3756
- const remount = resolveRemountProperty(unwrapped(entry.argument), declarations, configBindings, visiting, filename);
3757
- if (remount) {
3758
- return remount;
3775
+ const property = resolveConfigProperty(unwrapped(entry.argument), name, declarations, configBindings, visiting);
3776
+ if (property) {
3777
+ return property;
3759
3778
  }
3760
3779
  } else if (entry?.type === "Property") {
3761
3780
  const key = unwrapped(entry.key);
3762
- if (key?.type === "Identifier" && entry.computed !== true && key.name === "remountDeps" || key?.type === "Literal" && key.value === "remountDeps") {
3781
+ if (key?.type === "Identifier" && entry.computed !== true && key.name === name || key?.type === "Literal" && key.value === name) {
3763
3782
  return entry;
3764
3783
  }
3765
3784
  }
@@ -4303,8 +4322,8 @@ var ELYSIA_FILTER = /^elysia$/;
4303
4322
  var BUN_BUILTIN_FILTER = /^bun:/;
4304
4323
  var ANY_FILTER = /.*/;
4305
4324
  var elysiaStub = (typeModule) => `export * as t from ${JSON.stringify(typeModule)};
4325
+ export { ElysiaError, ElysiaStatus, HTTPError, InternalServerError, InvalidCookie, NotFound, ParseError, ValidationError, problem, status, validationDetail } from ${JSON.stringify(Bun.resolveSync("elysia/error", dirname4(typeModule)))};
4306
4326
  export class NotFoundError extends Error { constructor(m) { super(m); this.name = "NotFoundError"; } }
4307
- export class ValidationError extends Error { constructor(m) { super(m); this.name = "ValidationError"; } }
4308
4327
  export default {};
4309
4328
  `;
4310
4329
  var ELYSIA_STUB_PREFIX = "elysia-stub:";
@@ -25,11 +25,12 @@ export interface ManifestRoute {
25
25
  pattern: string;
26
26
  sourcePath: string;
27
27
  }
28
- /** A Next.js-style `error` / `not-found` pair declared in one directory. */
28
+ /** The Next.js-style `error` / `not-found` / `loading` files declared in one directory. */
29
29
  export interface ManifestBoundary {
30
30
  directory: string;
31
31
  errorPath: string | undefined;
32
32
  notFoundPath: string | undefined;
33
+ pendingPath: string | undefined;
33
34
  }
34
35
  export interface RouteManifest {
35
36
  /** Directory boundaries, shallow → deep. Always empty in the TanStack style. */
@@ -4,7 +4,7 @@ import { type RouteChains } from "./route-chains.ts";
4
4
  export interface StrippedCode {
5
5
  /** Config bindings the stripped `.config()` calls referenced. */
6
6
  configBindings: Set<string>;
7
- /** Names the retained remount policy references. */
7
+ /** Names the retained client policies reference. */
8
8
  retained: Set<string>;
9
9
  }
10
10
  export declare function removeChainedServerCalls(module: ModuleTransform, bindings: FactoryBindings, chains: RouteChains, stripped: StrippedCode): boolean;
@@ -88,6 +88,7 @@ export interface CompileContext {
88
88
  errorPath?: string;
89
89
  fromRoute?: true;
90
90
  notFoundPath?: string;
91
+ pendingPath?: string;
91
92
  }>;
92
93
  }>;
93
94
  routes: CompileContextRoute[];
@@ -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) {
@@ -8512,7 +8524,14 @@ function withDocumentState(element, assets, head, data, nonce, jsonCompatible) {
8512
8524
 
8513
8525
  // src/client/link.tsx
8514
8526
  init_search_params();
8515
- import { createElement as createElement6, useCallback as useCallback3, useEffect as useEffect2, useRef, useSyncExternalStore as useSyncExternalStore2 } from "react";
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";
8516
8535
 
8517
8536
  // src/client/router/context.ts
8518
8537
  init_link_utils();
@@ -8781,6 +8800,18 @@ function selectRouteBoundary(boundaries, rootBoundary, index, kind) {
8781
8800
  function wrapLayout(route, props, element) {
8782
8801
  return route?.layout ? createElement5(route.layout, props, element) : element;
8783
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
+ }
8784
8815
  function failureElement(failure, component, reset) {
8785
8816
  if (failure.status === "error") {
8786
8817
  return createElement5(component ?? DefaultErrorFallback, {
@@ -8805,9 +8836,10 @@ function resolveRouteElement(input) {
8805
8836
  inherited = { ...inherited, ...match.loaderData };
8806
8837
  props.push({ ...inherited, ...context });
8807
8838
  }
8839
+ const { pending } = input;
8808
8840
  const index = matches.findIndex((match) => match.status !== "success");
8809
8841
  const failure = matches[index];
8810
- if (failure && failure.status !== "success") {
8842
+ if (failure && failure.status !== "success" && !pending) {
8811
8843
  const { component, depth } = selectRouteBoundary(boundaries, input.rootBoundary, index, failure.status);
8812
8844
  let element = failureElement(failure, component, input.reset);
8813
8845
  for (let layout = depth;layout >= 0; layout -= 1) {
@@ -8819,18 +8851,10 @@ function resolveRouteElement(input) {
8819
8851
  throw new Error("[furin] internal invariant: a successful route render requires a page.");
8820
8852
  }
8821
8853
  const pageProps = Object.fromEntries(Object.entries(data).filter(([key]) => !key.startsWith("__furin")));
8822
- let element = createElement5(page.component, {
8854
+ const element = pending ? wrapSegments(input, pending.depth, props, pageProps, createElement5(pending.component)) : wrapSegments(input, chain.length - 1, props, pageProps, createElement5(page.component, {
8823
8855
  ...pageProps,
8824
8856
  key: pageKey(page.pattern, pageProps, chain.at(-1)?.remountDeps)
8825
- });
8826
- for (let layout = chain.length - 1;layout >= 0; layout -= 1) {
8827
- for (const boundary of boundaries.toReversed()) {
8828
- if (boundary.depth === layout) {
8829
- element = wrapSegmentBoundaries(element, boundary, input.boundaryOptions);
8830
- }
8831
- }
8832
- element = wrapLayout(chain[layout], props[layout] ?? pageProps, element);
8833
- }
8857
+ }));
8834
8858
  return withRouteSnapshot(element, page.pattern, pageProps);
8835
8859
  }
8836
8860
 
@@ -8937,6 +8961,7 @@ function LinkInteractive({
8937
8961
  replace,
8938
8962
  disabled,
8939
8963
  resetScroll,
8964
+ shallow,
8940
8965
  activeProps,
8941
8966
  inactiveProps,
8942
8967
  onClick,
@@ -8952,6 +8977,7 @@ function LinkInteractive({
8952
8977
  const anchorRef = useRef(null);
8953
8978
  const intentTimerRef = useRef(null);
8954
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]);
8955
8981
  const isActive = useSyncExternalStore2(store.subscribe, () => activeHref !== undefined && store.getCurrentHref() === activeHref, () => activeHref !== undefined && store.getCurrentHref() === activeHref);
8956
8982
  const { resolvedChildren, extraProps } = resolveLinkState({ activeProps, children, inactiveProps }, isActive);
8957
8983
  const effectivePreload = preload ?? router2.defaultPreload;
@@ -8965,9 +8991,9 @@ function LinkInteractive({
8965
8991
  }
8966
8992
  const target = shouldInterceptClick(anchor, { altKey: false, ctrlKey: false, metaKey: false, shiftKey: false }, router2.basePath, window.location.origin, window.location.pathname);
8967
8993
  if (target !== null) {
8968
- prefetch(target, { staleTime: effectiveStaleTime });
8994
+ prefetch(target, { search: targetSearch, staleTime: effectiveStaleTime });
8969
8995
  }
8970
- }, [prefetch, effectiveStaleTime, router2.basePath]);
8996
+ }, [prefetch, effectiveStaleTime, router2.basePath, targetSearch]);
8971
8997
  useEffect2(() => {
8972
8998
  if (effectivePreload === "render") {
8973
8999
  triggerPrefetch();
@@ -9017,7 +9043,7 @@ function LinkInteractive({
9017
9043
  window.location.assign(href);
9018
9044
  return;
9019
9045
  }
9020
- router2.navigate(target, { replace, resetScroll: resetScroll ?? true });
9046
+ router2.navigate(target, { replace, resetScroll, search: targetSearch, shallow });
9021
9047
  };
9022
9048
  const handleMouseEnter = (e) => {
9023
9049
  onMouseEnter?.(e);
@@ -9085,6 +9111,7 @@ function renderLinkElement(props, router2) {
9085
9111
  preloadStaleTime: _ps,
9086
9112
  replace: _r,
9087
9113
  resetScroll: _rs,
9114
+ shallow: _sh,
9088
9115
  onClick: _oc,
9089
9116
  onMouseEnter: _ome,
9090
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;
@@ -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` are included;
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
  */