@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.
Files changed (75) hide show
  1. package/dist/adapter/runtime-build.d.ts +1 -0
  2. package/dist/build/index.js +65 -25
  3. package/dist/build/route-metadata.d.ts +1 -1
  4. package/dist/cli/index.js +65 -25
  5. package/dist/client/chunks/{client-rdxyrw11.js → client-hjqd5m3b.js} +1 -1
  6. package/dist/client/chunks/{client-d9v49jwz.js → client-whph3y67.js} +66 -3
  7. package/dist/client/chunks/{client-a7spxfnn.js → client-xf7r768c.js} +13 -1
  8. package/dist/client/define-route.d.ts +12 -0
  9. package/dist/client/internal/runtime-types.d.ts +7 -0
  10. package/dist/client/link.js +200 -40
  11. package/dist/client/query.d.ts +13 -0
  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.d.ts +1 -1
  21. package/dist/client.js +21 -4
  22. package/dist/define-route.d.ts +37 -10
  23. package/dist/furin.js +92 -43
  24. package/dist/plugin/client-plugin.d.ts +1 -1
  25. package/dist/plugin/index.js +36 -17
  26. package/dist/plugin/route-manifest.d.ts +2 -1
  27. package/dist/plugin/strip-server-stages.d.ts +1 -1
  28. package/dist/server/dev/graph.d.ts +0 -1
  29. package/dist/server/internal.d.ts +1 -0
  30. package/dist/server/internal.js +46 -22
  31. package/dist/server/router/defined-route.d.ts +3 -0
  32. package/dist/server/router/hmr.d.ts +0 -1
  33. package/dist/server/router/source-version.d.ts +0 -1
  34. package/dist/server/router/types.d.ts +7 -1
  35. package/dist/server/static-export.js +49 -22
  36. package/dist/server/sync/index.js +1 -1
  37. package/dist/shared/pending.d.ts +13 -0
  38. package/dist/shared/search-params.d.ts +1 -0
  39. package/dist/sync-client.js +1 -1
  40. package/package.json +1 -1
  41. package/src/adapter/runtime-build.ts +4 -0
  42. package/src/build/hydrate.ts +11 -2
  43. package/src/build/preload-manifest.ts +3 -1
  44. package/src/build/route-metadata.ts +3 -2
  45. package/src/client/define-route.ts +23 -3
  46. package/src/client/internal/runtime-types.ts +7 -0
  47. package/src/client/link.tsx +26 -4
  48. package/src/client/query-store.ts +2 -1
  49. package/src/client/query.tsx +87 -0
  50. package/src/client/route-element.tsx +41 -15
  51. package/src/client/router/context.ts +29 -8
  52. package/src/client/router/history.ts +10 -0
  53. package/src/client/router/link-utils.ts +23 -0
  54. package/src/client/router/navigation-controller.ts +239 -19
  55. package/src/client/router/pending.ts +58 -0
  56. package/src/client/router/provider.tsx +5 -2
  57. package/src/client/router/search/index.ts +7 -2
  58. package/src/client/router/types.ts +29 -3
  59. package/src/client.ts +1 -1
  60. package/src/define-route.ts +74 -26
  61. package/src/plugin/client-plugin.ts +5 -4
  62. package/src/plugin/route-config.ts +9 -2
  63. package/src/plugin/route-manifest.ts +11 -3
  64. package/src/plugin/route-tree.ts +2 -2
  65. package/src/plugin/strip-server-stages.ts +60 -35
  66. package/src/server/dev/graph.ts +2 -7
  67. package/src/server/dev/runtime.ts +1 -2
  68. package/src/server/internal.ts +1 -0
  69. package/src/server/router/defined-route.ts +6 -0
  70. package/src/server/router/discovery.ts +5 -2
  71. package/src/server/router/hmr.ts +1 -5
  72. package/src/server/router/source-version.ts +3 -6
  73. package/src/server/router/types.ts +7 -1
  74. package/src/shared/pending.ts +16 -0
  75. 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
  });
@@ -1318,7 +1328,6 @@ class DevGraph {
1318
1328
  #eventSequence = 0;
1319
1329
  #revision = 0;
1320
1330
  #snapshot;
1321
- #sourceGeneration = 0;
1322
1331
  constructor(initialSnapshot) {
1323
1332
  this.#snapshot = initialSnapshot;
1324
1333
  }
@@ -1521,9 +1530,6 @@ class DevGraph {
1521
1530
  }
1522
1531
  }
1523
1532
  }
1524
- invalidateModules() {
1525
- this.#sourceGeneration += 1;
1526
- }
1527
1533
  sourceVersion(path) {
1528
1534
  const modulePath = normalizeModulePath(path);
1529
1535
  const fingerprint = this.#sourceFingerprint(modulePath, new Set);
@@ -1543,9 +1549,9 @@ class DevGraph {
1543
1549
  let ownFingerprint;
1544
1550
  try {
1545
1551
  const stats = statSync(path, { bigint: true });
1546
- ownFingerprint = `${stats.mtimeNs}:${stats.size}:${this.#sourceGeneration}`;
1552
+ ownFingerprint = `${stats.mtimeNs}:${stats.size}`;
1547
1553
  } catch {
1548
- ownFingerprint = `missing:${this.#sourceGeneration}`;
1554
+ ownFingerprint = "missing";
1549
1555
  }
1550
1556
  const dependencies = [...this.#dependencies.get(path) ?? []].toSorted((left, right) => left.localeCompare(right)).map((dependency) => this.#sourceFingerprint(dependency, visited));
1551
1557
  return `${path}:${ownFingerprint}:${dependencies.join(",")}`;
@@ -4579,10 +4585,10 @@ class QueryStore {
4579
4585
  }
4580
4586
  }
4581
4587
  entry.snapshot = { ...entry.snapshot, data };
4588
+ this.revisionValue += 1;
4582
4589
  for (const listener of entry.listeners) {
4583
4590
  listener();
4584
4591
  }
4585
- this.revisionValue += 1;
4586
4592
  for (const listener of this.listeners) {
4587
4593
  listener();
4588
4594
  }
@@ -4906,6 +4912,18 @@ function applyLinkParams(to, params) {
4906
4912
  }
4907
4913
  return url;
4908
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
+ }
4909
4927
  function buildHref(to, search, hash, searchDefaults) {
4910
4928
  let url = to;
4911
4929
  if (search && Object.keys(search).length > 0) {
@@ -7951,9 +7969,6 @@ function routeModuleSourceVersion(path) {
7951
7969
  });
7952
7970
  return String(Math.max(...(relevant.length > 0 ? relevant : [current]).map((graph) => Number(graph.sourceVersion(path)))));
7953
7971
  }
7954
- function invalidateRouteModuleSourceVersions() {
7955
- devGraph(undefined).invalidateModules();
7956
- }
7957
7972
  var init_source_version = __esm(() => {
7958
7973
  init_graph();
7959
7974
  init_instance();
@@ -10074,6 +10089,7 @@ import {
10074
10089
  useCallback,
10075
10090
  useContext as useContext2,
10076
10091
  useEffect,
10092
+ useState,
10077
10093
  useSyncExternalStore
10078
10094
  } from "react";
10079
10095
  var QUERY_CONTEXT2, contextGlobal2, QueryStoreContext;
@@ -10514,7 +10530,14 @@ var init_search_store = __esm(() => {
10514
10530
  var init_router = () => {};
10515
10531
 
10516
10532
  // src/client/link.tsx
10517
- 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";
10518
10541
  import { jsxDEV as jsxDEV2 } from "react/jsx-dev-runtime";
10519
10542
  function resolveLinkHref({ to, params, search, hash }, router2) {
10520
10543
  const resolvedTo = applyLinkParams(to, params);
@@ -10553,6 +10576,7 @@ function LinkInteractive({
10553
10576
  replace,
10554
10577
  disabled,
10555
10578
  resetScroll,
10579
+ shallow,
10556
10580
  activeProps,
10557
10581
  inactiveProps,
10558
10582
  onClick,
@@ -10568,6 +10592,7 @@ function LinkInteractive({
10568
10592
  const anchorRef = useRef(null);
10569
10593
  const intentTimerRef = useRef(null);
10570
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]);
10571
10596
  const isActive = useSyncExternalStore2(store.subscribe, () => activeHref !== undefined && store.getCurrentHref() === activeHref, () => activeHref !== undefined && store.getCurrentHref() === activeHref);
10572
10597
  const { resolvedChildren, extraProps } = resolveLinkState({ activeProps, children, inactiveProps }, isActive);
10573
10598
  const effectivePreload = preload ?? router2.defaultPreload;
@@ -10581,9 +10606,9 @@ function LinkInteractive({
10581
10606
  }
10582
10607
  const target = shouldInterceptClick(anchor, { altKey: false, ctrlKey: false, metaKey: false, shiftKey: false }, router2.basePath, window.location.origin, window.location.pathname);
10583
10608
  if (target !== null) {
10584
- prefetch(target, { staleTime: effectiveStaleTime });
10609
+ prefetch(target, { search: targetSearch, staleTime: effectiveStaleTime });
10585
10610
  }
10586
- }, [prefetch, effectiveStaleTime, router2.basePath]);
10611
+ }, [prefetch, effectiveStaleTime, router2.basePath, targetSearch]);
10587
10612
  useEffect2(() => {
10588
10613
  if (effectivePreload === "render") {
10589
10614
  triggerPrefetch();
@@ -10633,7 +10658,7 @@ function LinkInteractive({
10633
10658
  window.location.assign(href);
10634
10659
  return;
10635
10660
  }
10636
- router2.navigate(target, { replace, resetScroll: resetScroll ?? true });
10661
+ router2.navigate(target, { replace, resetScroll, search: targetSearch, shallow });
10637
10662
  };
10638
10663
  const handleMouseEnter = (e) => {
10639
10664
  onMouseEnter?.(e);
@@ -10687,6 +10712,7 @@ function renderLinkElement(props, router2) {
10687
10712
  preloadStaleTime: _ps,
10688
10713
  replace: _r,
10689
10714
  resetScroll: _rs,
10715
+ shallow: _sh,
10690
10716
  onClick: _oc,
10691
10717
  onMouseEnter: _ome,
10692
10718
  onMouseLeave: _oml,
@@ -11176,6 +11202,18 @@ function selectRouteBoundary(boundaries, rootBoundary, index, kind) {
11176
11202
  function wrapLayout(route, props, element) {
11177
11203
  return route?.layout ? createElement6(route.layout, props, element) : element;
11178
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
+ }
11179
11217
  function failureElement(failure, component, reset) {
11180
11218
  if (failure.status === "error") {
11181
11219
  return createElement6(component ?? DefaultErrorFallback, {
@@ -11200,9 +11238,10 @@ function resolveRouteElement(input) {
11200
11238
  inherited = { ...inherited, ...match.loaderData };
11201
11239
  props.push({ ...inherited, ...context });
11202
11240
  }
11241
+ const { pending } = input;
11203
11242
  const index = matches.findIndex((match) => match.status !== "success");
11204
11243
  const failure = matches[index];
11205
- if (failure && failure.status !== "success") {
11244
+ if (failure && failure.status !== "success" && !pending) {
11206
11245
  const { component, depth } = selectRouteBoundary(boundaries, input.rootBoundary, index, failure.status);
11207
11246
  let element = failureElement(failure, component, input.reset);
11208
11247
  for (let layout = depth;layout >= 0; layout -= 1) {
@@ -11214,18 +11253,10 @@ function resolveRouteElement(input) {
11214
11253
  throw new Error("[furin] internal invariant: a successful route render requires a page.");
11215
11254
  }
11216
11255
  const pageProps = Object.fromEntries(Object.entries(data).filter(([key]) => !key.startsWith("__furin")));
11217
- 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, {
11218
11257
  ...pageProps,
11219
11258
  key: pageKey(page.pattern, pageProps, chain.at(-1)?.remountDeps)
11220
- });
11221
- for (let layout = chain.length - 1;layout >= 0; layout -= 1) {
11222
- for (const boundary of boundaries.toReversed()) {
11223
- if (boundary.depth === layout) {
11224
- element = wrapSegmentBoundaries(element, boundary, input.boundaryOptions);
11225
- }
11226
- }
11227
- element = wrapLayout(chain[layout], props[layout] ?? pageProps, element);
11228
- }
11259
+ }));
11229
11260
  return withRouteSnapshot(element, page.pattern, pageProps);
11230
11261
  }
11231
11262
  var init_route_element = __esm(() => {
@@ -15248,6 +15279,8 @@ function addNextFile(state, base, segments, sourcePath) {
15248
15279
  state.boundary.errorPath ??= sourcePath;
15249
15280
  } else if (base === "not-found") {
15250
15281
  state.boundary.notFoundPath ??= sourcePath;
15282
+ } else if (base === "loading") {
15283
+ state.boundary.pendingPath ??= sourcePath;
15251
15284
  }
15252
15285
  }
15253
15286
  function scanNext(pagesDir) {
@@ -15255,7 +15288,12 @@ function scanNext(pagesDir) {
15255
15288
  const boundaries = [];
15256
15289
  let rootPath;
15257
15290
  const walk = (directory, segments) => {
15258
- const boundary = { directory, errorPath: undefined, notFoundPath: undefined };
15291
+ const boundary = {
15292
+ directory,
15293
+ errorPath: undefined,
15294
+ notFoundPath: undefined,
15295
+ pendingPath: undefined
15296
+ };
15259
15297
  const state = { boundary, candidates, rootPath };
15260
15298
  for (const entry of sortedEntries(directory)) {
15261
15299
  const sourcePath = child(directory, entry.name);
@@ -15266,7 +15304,7 @@ function scanNext(pagesDir) {
15266
15304
  }
15267
15305
  }
15268
15306
  rootPath ??= state.rootPath;
15269
- if (boundary.errorPath || boundary.notFoundPath) {
15307
+ if (boundary.errorPath || boundary.notFoundPath || boundary.pendingPath) {
15270
15308
  boundaries.push(boundary);
15271
15309
  }
15272
15310
  };
@@ -15401,6 +15439,7 @@ function adaptDefinedLayout(route, parent, sourcePath) {
15401
15439
  notFoundComponent: route.notFoundComponent,
15402
15440
  params: route.schemas?.params,
15403
15441
  ...parent ? { parent } : {},
15442
+ pending: route.pending,
15404
15443
  query: route.schemas?.query,
15405
15444
  requestLoader: route.requestLoader,
15406
15445
  revalidate: route.revalidate,
@@ -15418,6 +15457,7 @@ function adaptDefinedPage(route, parent) {
15418
15457
  __type: "FURIN_ROUTE",
15419
15458
  params: route.schemas?.params,
15420
15459
  parent,
15460
+ loaderDeps: route.loaderDeps,
15421
15461
  query: route.schemas?.query,
15422
15462
  remountDeps: route.remountDeps,
15423
15463
  requestLoader: route.requestLoader
@@ -15428,6 +15468,7 @@ function adaptDefinedPage(route, parent) {
15428
15468
  loader: route.loader,
15429
15469
  mode: route.mode,
15430
15470
  notFoundComponent: route.notFoundComponent,
15471
+ pending: route.pending,
15431
15472
  revalidate: route.revalidate,
15432
15473
  staticParams: route.staticParams,
15433
15474
  tags: copyTags(route.tags)
@@ -15667,8 +15708,8 @@ function routeDefinedBoundaries(root, routeChain, page, pagePath) {
15667
15708
  ];
15668
15709
  const pagesDir = root.path.slice(0, root.path.lastIndexOf("/"));
15669
15710
  return entries.flatMap(({ depth, path, route }) => {
15670
- const { errorComponent, notFoundComponent } = route;
15671
- if (path === undefined || !(errorComponent || notFoundComponent)) {
15711
+ const { errorComponent, notFoundComponent, pending } = route;
15712
+ if (path === undefined || !(errorComponent || notFoundComponent || pending)) {
15672
15713
  return [];
15673
15714
  }
15674
15715
  return [
@@ -15679,7 +15720,8 @@ function routeDefinedBoundaries(root, routeChain, page, pagePath) {
15679
15720
  fromRoute: true,
15680
15721
  notFound: notFoundComponent,
15681
15722
  notFoundPath: notFoundComponent ? path : undefined,
15682
- path: path === root.path ? pagesDir : path
15723
+ path: path === root.path ? pagesDir : path,
15724
+ pendingPath: pending ? path : undefined
15683
15725
  }
15684
15726
  ];
15685
15727
  });
@@ -15735,7 +15777,8 @@ async function collectSegmentBoundaries(pageAbsolutePath, boundaries, cache) {
15735
15777
  errorPath: errorEntry?.path,
15736
15778
  notFound: notFoundEntry?.component,
15737
15779
  notFoundPath: notFoundEntry?.path,
15738
- path: boundary.directory
15780
+ path: boundary.directory,
15781
+ pendingPath: boundary.pendingPath
15739
15782
  }));
15740
15783
  cache.set(boundary.directory, loaded);
15741
15784
  return loaded;
@@ -16962,9 +17005,6 @@ function importStampedRouteModule(path, resolveImport) {
16962
17005
  const stamp = routeModuleSourceVersion(path);
16963
17006
  return devGraph(undefined).importModule(path, stamp, resolveImport);
16964
17007
  }
16965
- function invalidateStampedRouteModules() {
16966
- invalidateRouteModuleSourceVersions();
16967
- }
16968
17008
  function isResolvedRouteModuleCandidate(layoutPath, imported, ctx) {
16969
17009
  if (existsSync6(layoutPath) || ctx?.modules[layoutPath]) {
16970
17010
  return true;
@@ -21749,7 +21789,7 @@ function routeSnapshotSourcePaths(instance) {
21749
21789
  return [
21750
21790
  ...existsSync9(rootPath) ? [rootPath] : [],
21751
21791
  ...routes.map(({ sourcePath }) => sourcePath),
21752
- ...boundaries.flatMap(({ errorPath, notFoundPath }) => [errorPath, notFoundPath].filter((path) => path !== undefined))
21792
+ ...boundaries.flatMap(({ errorPath, notFoundPath, pendingPath }) => [errorPath, notFoundPath, pendingPath].filter((path) => path !== undefined))
21753
21793
  ].map((path) => resolve8(path)).toSorted((left, right) => left.localeCompare(right));
21754
21794
  }
21755
21795
  var init_route_tree = __esm(() => {
@@ -22286,11 +22326,11 @@ function checkParams(file, route, parsed) {
22286
22326
  ${paramsSchema(missing)}`);
22287
22327
  }
22288
22328
  function checkBoundaryMethods(file, instance, parsed) {
22289
- const method = ["error", "notFound"].find((name) => parsed.route.methods.has(name));
22329
+ const method = BOUNDARY_METHODS.find((name) => parsed.route.methods.has(name));
22290
22330
  if (instance.style !== "nextjs" || method === undefined) {
22291
22331
  return;
22292
22332
  }
22293
- const convention = method === "error" ? "an error.tsx" : "a not-found.tsx";
22333
+ const convention = BOUNDARY_CONVENTIONS[method];
22294
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.`);
22295
22335
  }
22296
22336
  function checkRoute(file, instance, route, parsed) {
@@ -22382,7 +22422,7 @@ function scaffoldEmptyRoutes(spec) {
22382
22422
  }
22383
22423
  return written;
22384
22424
  }
22385
- 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";
22386
22426
 
22387
22427
  export const route = defineRootRoute()
22388
22428
  .config({ mode: "ssr" })
@@ -22404,6 +22444,12 @@ var init_route_config = __esm(() => {
22404
22444
  init_route_chains();
22405
22445
  init_route_manifest();
22406
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"];
22407
22453
  });
22408
22454
 
22409
22455
  // src/build/route-metadata.ts
@@ -22612,7 +22658,8 @@ function hydrateEntry(routes, rootLayout, basePath, clientLogging, modulePathKey
22612
22658
  for (const seg of route.segmentBoundaries ?? []) {
22613
22659
  const errorIdent = getBoundaryIdent(boundaryIdents, seg.errorPath);
22614
22660
  const notFoundIdent = getBoundaryIdent(boundaryIdents, seg.notFoundPath);
22615
- if (!(errorIdent || notFoundIdent)) {
22661
+ const pendingIdent = getBoundaryIdent(boundaryIdents, seg.pendingPath);
22662
+ if (!(errorIdent || notFoundIdent || pendingIdent)) {
22616
22663
  continue;
22617
22664
  }
22618
22665
  const parts = [`depth: ${seg.depth}`];
@@ -22624,6 +22671,9 @@ function hydrateEntry(routes, rootLayout, basePath, clientLogging, modulePathKey
22624
22671
  if (notFoundIdent) {
22625
22672
  parts.push(`notFound: ${notFoundIdent}.${notFoundExport}`);
22626
22673
  }
22674
+ if (pendingIdent) {
22675
+ parts.push(seg.fromRoute ? `pending: ${pendingIdent}.route.pending` : `pending: { component: ${pendingIdent}.default, minMs: ${pendingIdent}.pendingMinMs, ms: ${pendingIdent}.pendingMs }`);
22676
+ }
22627
22677
  if (seg.depth === 0 && seg.path.replaceAll("\\", "/") !== rootDirectory) {
22628
22678
  parts.push("isRoot: false");
22629
22679
  }
@@ -22642,7 +22692,7 @@ function hydrateEntry(routes, rootLayout, basePath, clientLogging, modulePathKey
22642
22692
  }).join(" ");
22643
22693
  const boundaryResult = boundaryLiterals.length > 0 ? `, segmentBoundaries: [${boundaryLiterals.join(", ")}]` : "";
22644
22694
  const pageComponentKey = JSON.stringify(`page:${modulePathKey(resolvedPage)}`);
22645
- 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} }; })`;
22646
22696
  const searchDefaultsEntry = searchDefaults ? `, searchDefaults: ${JSON.stringify(searchDefaults)}` : "";
22647
22697
  routeEntries.push(` { pattern: ${JSON.stringify(route.pattern)}, regex: new RegExp(${JSON.stringify(regexPattern)}), load: () => ${loadBody}${searchDefaultsEntry} }`);
22648
22698
  }
@@ -23629,7 +23679,6 @@ async function createDevRuntime(instance, resolvedPagesDir, style, options) {
23629
23679
  reportRouteConfig();
23630
23680
  const hmrEntry = (await import(join9(furinDir, "index.html"))).default;
23631
23681
  const refreshDevelopmentRoutes = (changedSources) => withInstance(instance, async () => {
23632
- invalidateStampedRouteModules();
23633
23682
  try {
23634
23683
  const previousSnapshot = currentSnapshot();
23635
23684
  const repaired = repairedDevelopmentRoutes(previousSnapshot, changedSources, graph);
@@ -25532,7 +25581,7 @@ function createLocalSyncClient(options) {
25532
25581
  var furinSync2 = furinSync;
25533
25582
  var invalidateSync2 = invalidateSync;
25534
25583
  // src/shared/await.tsx
25535
- 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";
25536
25585
  var AsyncErrorContext = createContext8(undefined);
25537
25586
  function useAsyncError() {
25538
25587
  return use3(AsyncErrorContext);
@@ -25584,7 +25633,7 @@ class AsyncErrorBoundary extends Component2 {
25584
25633
  }
25585
25634
  }
25586
25635
  function Await({ resolve, errorElement, children }) {
25587
- const guardedResolve = useMemo2(() => silenceAbortError(resolve), [resolve]);
25636
+ const guardedResolve = useMemo3(() => silenceAbortError(resolve), [resolve]);
25588
25637
  return createElement11(AsyncErrorBoundary, { errorElement, resolve: guardedResolve }, createElement11(AwaitInner, { children, resolve: guardedResolve }));
25589
25638
  }
25590
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;
@@ -74,7 +74,6 @@ export declare class DevGraph<Snapshot> {
74
74
  recordImports(importer: string, imports: string[]): void;
75
75
  recordSourceError(message: string, position: DevSourcePosition): void;
76
76
  sourceError(message: string, entryPath: string): DevSourcePosition | undefined;
77
- invalidateModules(): void;
78
77
  sourceVersion(path: string): string;
79
78
  state<Value>(key: symbol, initialize: () => Value): Value;
80
79
  subscribe(after: number, serverId: string | undefined, listener: (event: DevGraphEvent) => void): {
@@ -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[];