@teyik0/furin 0.1.0-alpha.7 → 0.1.0-alpha.9

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 (46) hide show
  1. package/dist/adapter/static.d.ts +3 -0
  2. package/dist/build/client.d.ts +3 -3
  3. package/dist/build/compile-entry.d.ts +4 -4
  4. package/dist/build/entry-template.d.ts +2 -2
  5. package/dist/build/hydrate.d.ts +6 -2
  6. package/dist/build/index.d.ts +1 -1
  7. package/dist/build/index.js +1491 -78
  8. package/dist/build/types.d.ts +26 -3
  9. package/dist/cli/index.js +1525 -91
  10. package/dist/client.d.ts +18 -11
  11. package/dist/config.d.ts +33 -2
  12. package/dist/config.js +6 -1
  13. package/dist/context-logger.d.ts +26 -0
  14. package/dist/dev-page-plugin.d.ts +77 -0
  15. package/dist/furin.js +459 -69
  16. package/dist/link.d.ts +31 -3
  17. package/dist/link.js +198 -51
  18. package/dist/render/assemble.d.ts +4 -2
  19. package/dist/render/index.d.ts +1 -1
  20. package/dist/render/loaders.d.ts +1 -1
  21. package/dist/render/shell.d.ts +4 -1
  22. package/dist/router.d.ts +11 -0
  23. package/dist/router.js +942 -41
  24. package/package.json +6 -5
  25. package/src/adapter/bun.ts +20 -0
  26. package/src/adapter/static.ts +341 -0
  27. package/src/build/client.ts +21 -11
  28. package/src/build/compile-entry.ts +5 -3
  29. package/src/build/entry-template.ts +2 -2
  30. package/src/build/hydrate.ts +37 -9
  31. package/src/build/index.ts +56 -21
  32. package/src/build/scan-server.ts +43 -21
  33. package/src/build/types.ts +28 -3
  34. package/src/cli/index.ts +13 -5
  35. package/src/client.ts +19 -25
  36. package/src/config.ts +35 -1
  37. package/src/context-logger.ts +71 -0
  38. package/src/dev-page-plugin.ts +339 -4
  39. package/src/furin.ts +6 -2
  40. package/src/link.tsx +355 -64
  41. package/src/plugin/index.ts +2 -2
  42. package/src/render/assemble.ts +4 -2
  43. package/src/render/index.ts +67 -23
  44. package/src/render/loaders.ts +81 -36
  45. package/src/render/shell.ts +11 -4
  46. package/src/router.ts +55 -6
package/dist/link.d.ts CHANGED
@@ -109,7 +109,13 @@ export declare function shouldAutoRefreshPath(currentPath: string, invalidations
109
109
  type: "page" | "layout";
110
110
  }>): boolean;
111
111
  export interface RouterContextValue {
112
- /** Current pathname + search (no hash). Used by Link for active-state detection. */
112
+ /**
113
+ * Sub-path prefix for static deployments (e.g. "/furin").
114
+ * Empty string when the site is served from root.
115
+ * Used by `Link` to build correct physical hrefs for the `<a>` element.
116
+ */
117
+ basePath: string;
118
+ /** Current **logical** pathname + search (basePath stripped). Used by Link for active-state detection. */
113
119
  currentHref: string;
114
120
  defaultPreload: PreloadStrategy;
115
121
  defaultPreloadDelay: number;
@@ -185,6 +191,17 @@ export interface RouterProviderProps {
185
191
  * Set to `false` to opt out and call `router.refresh()` manually instead.
186
192
  */
187
193
  autoRefresh?: boolean;
194
+ /**
195
+ * Sub-path prefix for static deployments (e.g. "/furin").
196
+ * Must start with "/" and have no trailing slash.
197
+ * Default: "" (site served from root).
198
+ *
199
+ * When set:
200
+ * - `currentHref` stores **logical** paths (prefix stripped) for correct active-state detection.
201
+ * - `navigate(logicalHref)` pushes `basePath + logicalHref` to browser history.
202
+ * - `fetch` calls use the physical path `basePath + logicalHref`.
203
+ */
204
+ basePath?: string;
188
205
  defaultPreload?: PreloadStrategy;
189
206
  defaultPreloadDelay?: number;
190
207
  defaultPreloadStaleTime?: number;
@@ -212,6 +229,17 @@ export interface CacheEntry {
212
229
  export declare function shouldRefetch(entry: CacheEntry): boolean;
213
230
  /** @internal Exported for unit testing only. */
214
231
  export declare function buildPageElement(match: LoadedClientRoute, root: RuntimeRoute | null, data: Record<string, unknown>): React.ReactNode;
215
- export declare function RouterProvider({ routes, root, initialMatch, initialData, autoRefresh, defaultPreload, defaultPreloadDelay, defaultPreloadStaleTime, prefetchCacheSize, }: RouterProviderProps): React.ReactElement;
216
- export declare function Link<To extends RouteTo>({ to, search, hash, preload, preloadDelay, preloadStaleTime, replace, disabled, resetScroll, activeProps, inactiveProps, onClick, onMouseEnter, onMouseLeave, onFocus, children, ...anchorProps }: LinkProps<To>): React.ReactElement;
232
+ export declare function RouterProvider({ routes, root, initialMatch, initialData, autoRefresh, basePath, defaultPreload, defaultPreloadDelay, defaultPreloadStaleTime, prefetchCacheSize, }: RouterProviderProps): React.ReactElement;
233
+ /**
234
+ * SSR-aware Link component.
235
+ *
236
+ * - **Server (SSR):** uses `RouterContext.Consumer` (a render-prop, not a hook)
237
+ * to read basePath / currentHref from any enclosing RouterProvider, then
238
+ * falls back to `SSR_FALLBACK_ROUTER` when no provider is present.
239
+ * `Context.Consumer` bypasses `ReactCurrentDispatcher` entirely, so it is
240
+ * safe even when two React instances coexist in the module graph (Bun HMR).
241
+ * - **Client:** delegates to `LinkInteractive` which adds preloading, SPA
242
+ * navigation, active-state tracking and all other interactive features.
243
+ */
244
+ export declare function Link<To extends RouteTo>(props: LinkProps<To>): React.ReactElement;
217
245
  export {};
package/dist/link.js CHANGED
@@ -1,5 +1,5 @@
1
1
  // @bun
2
- // ../../node_modules/.bun/evlog@2.12.0+f7c24eab1d196b1d/node_modules/evlog/dist/utils.mjs
2
+ // ../../node_modules/.bun/evlog@2.13.0+449e6d239244fccb/node_modules/evlog/dist/utils.mjs
3
3
  function formatDuration(ms) {
4
4
  if (ms < 1000)
5
5
  return `${Math.round(ms)}ms`;
@@ -82,7 +82,7 @@ function escapeFormatString(str) {
82
82
  return str.replace(/%/g, "%%");
83
83
  }
84
84
 
85
- // ../../node_modules/.bun/evlog@2.12.0+f7c24eab1d196b1d/node_modules/evlog/dist/logger-DY0X5oQd.mjs
85
+ // ../../node_modules/.bun/evlog@2.13.0+449e6d239244fccb/node_modules/evlog/dist/logger-DnobymUQ.mjs
86
86
  var DEFAULT_REPLACEMENT = "[REDACTED]";
87
87
  var builtinPatterns = {
88
88
  creditCard: {
@@ -676,7 +676,8 @@ function shouldAutoRefreshPath(currentPath, invalidations) {
676
676
  var RouterContext = createContext(null);
677
677
  function useRouter() {
678
678
  return useContext(RouterContext) ?? {
679
- currentHref: typeof window === "undefined" ? "/" : window.location.pathname + window.location.search,
679
+ basePath: "",
680
+ currentHref: "/",
680
681
  navigate: (href) => {
681
682
  window.location.href = href;
682
683
  return Promise.resolve();
@@ -745,15 +746,58 @@ function handleScrollRestoration(href, navigationToken, navVersion) {
745
746
  });
746
747
  });
747
748
  } else {
748
- window.scrollTo(0, 0);
749
+ window.scrollTo({ top: 0, behavior: "instant" });
749
750
  }
750
751
  }
752
+ var SCROLL_STORAGE_KEY = "__furin_scroll__";
753
+ function getHistoryKey(state) {
754
+ return state?._furinKey;
755
+ }
756
+ function generateHistoryKey() {
757
+ return Math.random().toString(36).slice(2, 9);
758
+ }
759
+ function saveScrollPosition(key) {
760
+ try {
761
+ const raw = sessionStorage.getItem(SCROLL_STORAGE_KEY);
762
+ const positions = raw ? JSON.parse(raw) : {};
763
+ positions[key] = window.scrollY;
764
+ const keys = Object.keys(positions);
765
+ if (keys.length > 50) {
766
+ delete positions[keys[0]];
767
+ }
768
+ sessionStorage.setItem(SCROLL_STORAGE_KEY, JSON.stringify(positions));
769
+ } catch {}
770
+ }
771
+ function restoreScrollPosition(key, token, version) {
772
+ try {
773
+ const raw = sessionStorage.getItem(SCROLL_STORAGE_KEY);
774
+ const positions = raw ? JSON.parse(raw) : {};
775
+ const y = positions[key] ?? 0;
776
+ window.requestAnimationFrame(() => {
777
+ window.requestAnimationFrame(() => {
778
+ if (version.current !== token) {
779
+ return;
780
+ }
781
+ window.scrollTo({ top: y, behavior: "instant" });
782
+ });
783
+ });
784
+ } catch {
785
+ window.scrollTo({ top: 0, behavior: "instant" });
786
+ }
787
+ }
788
+ function toLogical(physicalPathname, basePath) {
789
+ if (basePath && physicalPathname.startsWith(basePath) && (physicalPathname.length === basePath.length || physicalPathname[basePath.length] === "/")) {
790
+ return physicalPathname.slice(basePath.length) || "/";
791
+ }
792
+ return physicalPathname;
793
+ }
751
794
  function RouterProvider({
752
795
  routes,
753
796
  root,
754
797
  initialMatch,
755
798
  initialData,
756
799
  autoRefresh = true,
800
+ basePath = "",
757
801
  defaultPreload = "intent",
758
802
  defaultPreloadDelay = 50,
759
803
  defaultPreloadStaleTime = 30000,
@@ -764,34 +808,41 @@ function RouterProvider({
764
808
  data: initialData
765
809
  });
766
810
  const [isNavigating, setIsNavigating] = useState(false);
767
- const [currentHref, setCurrentHref] = useState(() => typeof window === "undefined" ? "/" : window.location.pathname + window.location.search);
811
+ const [currentHref, setCurrentHref] = useState(() => {
812
+ if (typeof window === "undefined") {
813
+ return "/";
814
+ }
815
+ return toLogical(window.location.pathname, basePath) + window.location.search;
816
+ });
768
817
  const prefetchCache = useRef(new Map);
769
818
  const navVersion = useRef(0);
770
- const fetchPageState = useCallback(async (href) => {
819
+ const fetchPageState = useCallback(async (logicalHref) => {
771
820
  try {
772
- const url = new URL(href, window.location.origin);
773
- const match = routes.find((r) => r.regex.test(url.pathname));
821
+ const physicalHref = basePath + logicalHref;
822
+ const url = new URL(physicalHref, window.location.origin);
823
+ const logicalPathname = toLogical(url.pathname, basePath);
824
+ const match = routes.find((r) => r.regex.test(logicalPathname));
774
825
  if (!match) {
775
826
  return null;
776
827
  }
777
- const [res, loadedMod] = await Promise.all([fetch(href), match.load()]);
828
+ const [res, loadedMod] = await Promise.all([fetch(physicalHref), match.load()]);
778
829
  const serverBuildId = res.headers.get("x-furin-build-id");
779
830
  if (serverBuildId) {
780
831
  const metaEl = typeof document === "undefined" ? null : document.querySelector('meta[name="furin-build-id"]');
781
832
  const clientBuildId = metaEl?.content;
782
833
  if (clientBuildId && serverBuildId !== clientBuildId) {
783
- window.location.href = href;
834
+ window.location.href = physicalHref;
784
835
  return null;
785
836
  }
786
837
  }
787
838
  if (!res.ok) {
788
- _log.warn({ action: "navigate_server_error", href, status: res.status });
839
+ _log.warn({ action: "navigate_server_error", href: physicalHref, status: res.status });
789
840
  return null;
790
841
  }
791
842
  let finalHref;
792
843
  if (res.redirected) {
793
844
  const final = new URL(res.url);
794
- finalHref = final.pathname + final.search;
845
+ finalHref = toLogical(final.pathname, basePath) + final.search;
795
846
  }
796
847
  const html = await res.text();
797
848
  const doc = new DOMParser().parseFromString(html, "text/html");
@@ -804,10 +855,10 @@ function RouterProvider({
804
855
  };
805
856
  return { match: loadedMatch, data, title: doc.title, finalHref };
806
857
  } catch (err) {
807
- _log.error({ action: "navigate_failed", href, error: String(err) });
858
+ _log.error({ action: "navigate_failed", href: basePath + logicalHref, error: String(err) });
808
859
  return null;
809
860
  }
810
- }, [routes]);
861
+ }, [routes, basePath]);
811
862
  const invalidatePrefetch = useCallback((path, type = "page") => {
812
863
  const normalizedPath = stripHashFromHref(path);
813
864
  if (type === "page") {
@@ -842,63 +893,83 @@ function RouterProvider({
842
893
  prefetchCache.current.delete(oldest);
843
894
  }
844
895
  }, [fetchPageState, defaultPreloadStaleTime, prefetchCacheSize]);
845
- const navigate = useCallback(async (href, opts) => {
846
- prefetch(href);
896
+ const navigate = useCallback(async (logicalHref, opts) => {
897
+ prefetch(logicalHref);
847
898
  const myVersion = ++navVersion.current;
848
899
  setIsNavigating(true);
849
900
  try {
850
- const newState = await prefetchCache.current.get(href)?.promise;
901
+ const newState = await prefetchCache.current.get(logicalHref)?.promise;
851
902
  if (navVersion.current !== myVersion) {
852
903
  return;
853
904
  }
854
905
  if (!newState) {
855
- _log.warn({ action: "navigate_fallback", href, reason: "prefetch_returned_null" });
856
- window.location.href = href;
906
+ _log.warn({
907
+ action: "navigate_fallback",
908
+ href: logicalHref,
909
+ reason: "prefetch_returned_null"
910
+ });
911
+ window.location.href = basePath + logicalHref;
857
912
  return;
858
913
  }
859
914
  setState(newState);
860
915
  if (newState.title) {
861
916
  document.title = newState.title;
862
917
  }
863
- const effectiveHref = newState.finalHref ?? href;
918
+ const effectiveLogical = newState.finalHref ?? logicalHref;
919
+ const physicalEffective = basePath + effectiveLogical;
864
920
  if (opts?.replace) {
865
- window.history.replaceState(null, "", effectiveHref);
921
+ window.history.replaceState({
922
+ ...history.state ?? {},
923
+ _furinKey: getHistoryKey(history.state) ?? generateHistoryKey()
924
+ }, "", physicalEffective);
866
925
  } else {
867
- window.history.pushState(null, "", effectiveHref);
926
+ const currentKey = getHistoryKey(history.state);
927
+ if (currentKey) {
928
+ saveScrollPosition(currentKey);
929
+ }
930
+ window.history.pushState({ _furinKey: generateHistoryKey() }, "", physicalEffective);
868
931
  }
869
- const effectiveUrl = new URL(effectiveHref, window.location.origin);
870
- setCurrentHref(effectiveUrl.pathname + effectiveUrl.search);
932
+ const effectiveUrl = new URL(physicalEffective, window.location.origin);
933
+ const logicalPath = toLogical(effectiveUrl.pathname, basePath);
934
+ setCurrentHref(logicalPath + effectiveUrl.search);
871
935
  if (opts?.resetScroll ?? true) {
872
- handleScrollRestoration(effectiveHref, myVersion, navVersion);
936
+ handleScrollRestoration(physicalEffective, myVersion, navVersion);
873
937
  }
874
938
  } finally {
875
939
  if (navVersion.current === myVersion) {
876
940
  setIsNavigating(false);
877
941
  }
878
942
  }
879
- }, [prefetch]);
943
+ }, [prefetch, basePath]);
880
944
  const refresh = useCallback(async (opts) => {
881
- const href = window.location.pathname + window.location.search;
882
- invalidatePrefetch(href, "page");
883
- await navigate(href, { replace: true, resetScroll: opts?.resetScroll ?? false });
884
- }, [navigate, invalidatePrefetch]);
945
+ const logicalPath = toLogical(window.location.pathname, basePath);
946
+ const logicalHref = logicalPath + window.location.search;
947
+ invalidatePrefetch(logicalHref, "page");
948
+ await navigate(logicalHref, { replace: true, resetScroll: opts?.resetScroll ?? false });
949
+ }, [navigate, invalidatePrefetch, basePath]);
885
950
  const handlePopState = useCallback(async () => {
886
- const href = window.location.pathname + window.location.search;
951
+ const destKey = getHistoryKey(history.state);
952
+ const logicalPath = toLogical(window.location.pathname, basePath);
953
+ const logicalHref = logicalPath + window.location.search;
887
954
  const myVersion = ++navVersion.current;
888
955
  setIsNavigating(true);
889
956
  try {
890
- const cached = prefetchCache.current.get(href);
957
+ const cached = prefetchCache.current.get(logicalHref);
891
958
  let newState;
892
959
  if (cached && !shouldRefetch(cached)) {
893
960
  newState = await cached.promise;
894
961
  } else {
895
- newState = await fetchPageState(href);
962
+ newState = await fetchPageState(logicalHref);
896
963
  }
897
964
  if (navVersion.current !== myVersion) {
898
965
  return;
899
966
  }
900
967
  if (!newState) {
901
- _log.warn({ action: "popstate_fallback", href, reason: "fetchPageState_returned_null" });
968
+ _log.warn({
969
+ action: "popstate_fallback",
970
+ href: logicalHref,
971
+ reason: "fetchPageState_returned_null"
972
+ });
902
973
  window.location.reload();
903
974
  return;
904
975
  }
@@ -906,18 +977,32 @@ function RouterProvider({
906
977
  if (newState.title) {
907
978
  document.title = newState.title;
908
979
  }
909
- const effectiveHref = newState.finalHref ?? href;
980
+ const effectiveLogical = newState.finalHref ?? logicalHref;
910
981
  if (newState.finalHref) {
911
- window.history.replaceState(null, "", effectiveHref);
982
+ window.history.replaceState(history.state, "", basePath + effectiveLogical);
983
+ }
984
+ setCurrentHref(effectiveLogical);
985
+ if (destKey) {
986
+ restoreScrollPosition(destKey, myVersion, navVersion);
987
+ } else {
988
+ window.scrollTo({ top: 0, behavior: "instant" });
912
989
  }
913
- const effectiveUrl = new URL(effectiveHref, window.location.origin);
914
- setCurrentHref(effectiveUrl.pathname + effectiveUrl.search);
915
990
  } finally {
916
991
  if (navVersion.current === myVersion) {
917
992
  setIsNavigating(false);
918
993
  }
919
994
  }
920
- }, [fetchPageState]);
995
+ }, [fetchPageState, basePath]);
996
+ useEffect(() => {
997
+ const prevScrollRestoration = history.scrollRestoration;
998
+ history.scrollRestoration = "manual";
999
+ if (!getHistoryKey(history.state)) {
1000
+ history.replaceState({ ...history.state ?? {}, _furinKey: generateHistoryKey() }, "");
1001
+ }
1002
+ return () => {
1003
+ history.scrollRestoration = prevScrollRestoration;
1004
+ };
1005
+ }, []);
921
1006
  useEffect(() => {
922
1007
  window.addEventListener("popstate", handlePopState);
923
1008
  return () => window.removeEventListener("popstate", handlePopState);
@@ -950,6 +1035,7 @@ function RouterProvider({
950
1035
  }, [invalidatePrefetch, refresh, autoRefresh]);
951
1036
  return createElement(RouterContext.Provider, {
952
1037
  value: {
1038
+ basePath,
953
1039
  currentHref,
954
1040
  navigate,
955
1041
  prefetch,
@@ -962,7 +1048,26 @@ function RouterProvider({
962
1048
  }
963
1049
  }, buildPageElement(state.match, root, state.data));
964
1050
  }
965
- function Link({
1051
+ function computeLinkView({
1052
+ to,
1053
+ search,
1054
+ hash,
1055
+ children,
1056
+ activeProps,
1057
+ inactiveProps
1058
+ }, router) {
1059
+ const logicalHref = buildHref(to, search, hash);
1060
+ const logicalHrefWithoutHash = buildHref(to, search, undefined);
1061
+ const href = router.basePath + logicalHref;
1062
+ const isActive = router.currentHref === logicalHrefWithoutHash;
1063
+ const resolvedChildren = typeof children === "function" ? children({ isActive }) : children;
1064
+ const extraProps = {
1065
+ ...inactiveProps && !isActive ? inactiveProps() : {},
1066
+ ...activeProps ? activeProps({ isActive }) : {}
1067
+ };
1068
+ return { logicalHref, href, isActive, resolvedChildren, extraProps };
1069
+ }
1070
+ function LinkInteractive({
966
1071
  to,
967
1072
  search,
968
1073
  hash,
@@ -984,15 +1089,13 @@ function Link({
984
1089
  const router = useRouter();
985
1090
  const anchorRef = useRef(null);
986
1091
  const intentTimerRef = useRef(null);
987
- const href = buildHref(to, search, hash);
988
- const hrefWithoutHash = buildHref(to, search, undefined);
989
- const isActive = router.currentHref === hrefWithoutHash;
1092
+ const { logicalHref, href, isActive, resolvedChildren, extraProps } = computeLinkView({ to, search, hash, children, activeProps, inactiveProps }, router);
990
1093
  const effectivePreload = preload ?? router.defaultPreload;
991
1094
  const effectiveDelay = preloadDelay ?? router.defaultPreloadDelay;
992
1095
  const effectiveStaleTime = preloadStaleTime ?? router.defaultPreloadStaleTime;
993
1096
  const triggerPrefetch = useCallback(() => {
994
- router.prefetch(href, { staleTime: effectiveStaleTime });
995
- }, [router, href, effectiveStaleTime]);
1097
+ router.prefetch(logicalHref, { staleTime: effectiveStaleTime });
1098
+ }, [router, logicalHref, effectiveStaleTime]);
996
1099
  useEffect(() => {
997
1100
  if (effectivePreload === "render") {
998
1101
  triggerPrefetch();
@@ -1033,7 +1136,7 @@ function Link({
1033
1136
  return;
1034
1137
  }
1035
1138
  e.preventDefault();
1036
- router.navigate(href, { replace, resetScroll: resetScroll ?? true });
1139
+ router.navigate(logicalHref, { replace, resetScroll: resetScroll ?? true });
1037
1140
  };
1038
1141
  const handleMouseEnter = (e) => {
1039
1142
  onMouseEnter?.(e);
@@ -1054,11 +1157,6 @@ function Link({
1054
1157
  triggerPrefetch();
1055
1158
  }
1056
1159
  };
1057
- const resolvedChildren = typeof children === "function" ? children({ isActive }) : children;
1058
- const extraProps = {
1059
- ...inactiveProps && !isActive ? inactiveProps() : {},
1060
- ...activeProps ? activeProps({ isActive }) : {}
1061
- };
1062
1160
  return createElement("a", {
1063
1161
  ref: anchorRef,
1064
1162
  href,
@@ -1072,6 +1170,55 @@ function Link({
1072
1170
  ...disabled ? { "aria-disabled": true } : {}
1073
1171
  }, resolvedChildren);
1074
1172
  }
1173
+ var SSR_FALLBACK_ROUTER = {
1174
+ basePath: "",
1175
+ currentHref: "/",
1176
+ navigate: () => Promise.resolve(),
1177
+ prefetch: () => {},
1178
+ invalidatePrefetch: () => {},
1179
+ refresh: () => Promise.resolve(),
1180
+ isNavigating: false,
1181
+ defaultPreload: "intent",
1182
+ defaultPreloadDelay: 50,
1183
+ defaultPreloadStaleTime: 30000
1184
+ };
1185
+ function renderLinkElement(props, router) {
1186
+ const { href, isActive, resolvedChildren, extraProps } = computeLinkView(props, router);
1187
+ const {
1188
+ to: _to,
1189
+ search: _search,
1190
+ hash: _hash,
1191
+ children: _children,
1192
+ activeProps: _ap,
1193
+ inactiveProps: _ip,
1194
+ disabled,
1195
+ preload: _p,
1196
+ preloadDelay: _pd,
1197
+ preloadStaleTime: _ps,
1198
+ replace: _r,
1199
+ resetScroll: _rs,
1200
+ onClick: _oc,
1201
+ onMouseEnter: _ome,
1202
+ onMouseLeave: _oml,
1203
+ onFocus: _of,
1204
+ ...anchorProps
1205
+ } = props;
1206
+ return createElement("a", {
1207
+ href,
1208
+ ...isActive ? { "data-status": "active" } : {},
1209
+ ...anchorProps,
1210
+ ...extraProps,
1211
+ ...disabled ? { "aria-disabled": true } : {}
1212
+ }, resolvedChildren);
1213
+ }
1214
+ function Link(props) {
1215
+ if (typeof window === "undefined") {
1216
+ return createElement(RouterContext.Consumer, {
1217
+ children: (routerCtx) => renderLinkElement(props, routerCtx ?? SSR_FALLBACK_ROUTER)
1218
+ });
1219
+ }
1220
+ return createElement(LinkInteractive, props);
1221
+ }
1075
1222
  export {
1076
1223
  useRouter,
1077
1224
  shouldRefetch,
@@ -1,6 +1,8 @@
1
- import type { RouteContext } from "../client";
2
1
  import type { buildHeadInjection } from "./shell";
3
- export type LoaderContext = RouteContext<Record<string, string>, Record<string, string>>;
2
+ /** Minimal context passed to background / synthetic render helpers — only `request` is needed. */
3
+ export interface LoaderContext {
4
+ request: Request;
5
+ }
4
6
  export declare function resolvePath(pattern: string, params: Record<string, string>): string;
5
7
  export declare function streamToString(stream: ReadableStream): Promise<string>;
6
8
  interface SplitTemplate {
@@ -11,7 +11,7 @@ interface RenderResult {
11
11
  }
12
12
  export declare function renderToHTML(route: ResolvedRoute, ctx: Context, root: RootLayout): Promise<RenderResult>;
13
13
  export declare function renderToStream(route: ResolvedRoute, ctx: Context, root: RootLayout): Promise<ReadableStream | Response>;
14
- export declare function prerenderSSG(route: ResolvedRoute, params: Record<string, string>, root: RootLayout, origin?: string): Promise<SsgCacheEntry | Response>;
14
+ export declare function prerenderSSG(route: ResolvedRoute, params: Record<string, string>, root: RootLayout, origin?: string, basePath?: string): Promise<SsgCacheEntry | Response>;
15
15
  export declare function renderSSR(route: ResolvedRoute, ctx: Context, root: RootLayout): Promise<Response>;
16
16
  export declare function handleISR(route: ResolvedRoute, ctx: Context, root: RootLayout, buildId?: string): Promise<string | Response | undefined>;
17
17
  /**
@@ -9,4 +9,4 @@ export type LoaderResult = {
9
9
  type: "redirect";
10
10
  response: Response;
11
11
  };
12
- export declare function runLoaders(route: ResolvedRoute, ctx: Context, rootLayout: RuntimeRoute): Promise<LoaderResult>;
12
+ export declare function runLoaders(route: ResolvedRoute, ctx: Context, _rootLayout: RuntimeRoute): Promise<LoaderResult>;
@@ -22,5 +22,8 @@ export declare function generateIndexHtml(): string;
22
22
  *
23
23
  * @param buildId - Short hash identifying this specific build. Injected as a
24
24
  * `<meta name="furin-build-id">` tag so the client can detect stale deploys.
25
+ * @param faviconHref - Absolute href for the favicon (e.g. "/furin/favicon.ico").
26
+ * When provided, a `<link rel="icon">` tag is injected so browsers can locate
27
+ * the favicon even when the site is served from a sub-path.
25
28
  */
26
- export declare function generateProdIndexHtml(entryChunk: string, cssChunks: string[], buildId?: string): string;
29
+ export declare function generateProdIndexHtml(entryChunk: string, cssChunks: string[], buildId?: string, faviconHref?: string): string;
package/dist/router.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  import { type AnyElysia, type Context } from "elysia";
2
+ import type { AnySchema } from "elysia/types";
2
3
  import type { RuntimePage, RuntimeRoute } from "./client.ts";
3
4
  import { type CompileContext } from "./internal.ts";
4
5
  export interface ResolvedRoute {
@@ -29,6 +30,16 @@ export declare function scanPages(pagesDir: string): Promise<{
29
30
  export declare function scanRootLayout(pagesDir: string): Promise<RootLayout>;
30
31
  /** @internal Exported for unit testing. */
31
32
  export declare function queryDefaultRedirectHook({ request, query, status, set }: Context): import("elysia").ElysiaCustomStatusResponse<"Found", "Found", 302> | undefined;
33
+ /**
34
+ * Merges TObject schemas from all routeChain entries for a given key.
35
+ * Properties are spread left-to-right (leaf wins on key conflict).
36
+ * Object-level options (additionalProperties, $id, description, …) are also
37
+ * merged with the same leaf-wins semantics so they are not silently dropped.
38
+ * Returns undefined when no entry in the chain defines the key.
39
+ *
40
+ * @internal Exported for unit testing.
41
+ */
42
+ export declare function mergeRouteSchemas(routeChain: RuntimeRoute[], key: "params" | "query"): AnySchema | undefined;
32
43
  export declare function createRoutePlugin(route: ResolvedRoute, root: RootLayout, buildId?: string): AnyElysia;
33
44
  export declare function resolveMode(page: RuntimePage, routeChain: RuntimeRoute[]): "ssr" | "ssg" | "isr";
34
45
  export declare function filePathToPattern(path: string): string;