@teyik0/furin 0.1.0-alpha.12 → 0.1.0-alpha.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/link.js CHANGED
@@ -1197,10 +1197,12 @@ function stripHashFromHref(href) {
1197
1197
  return href.replace(HASH_FRAGMENT_RE, "");
1198
1198
  }
1199
1199
  function normalizeHref(href) {
1200
- if (href === "/") {
1201
- return "/";
1200
+ const url = new URL(href, "http://localhost");
1201
+ let pathname = url.pathname;
1202
+ if (pathname !== "/") {
1203
+ pathname = pathname.replace(/\/+$/g, "");
1202
1204
  }
1203
- return href.replace(/\/+(\?|#|$)/g, "$1");
1205
+ return pathname + url.search + url.hash;
1204
1206
  }
1205
1207
  function normalizePath(path) {
1206
1208
  if (path === "/" || path === "") {
@@ -1407,7 +1409,7 @@ function RouterProvider({
1407
1409
  if (typeof window === "undefined") {
1408
1410
  return "/";
1409
1411
  }
1410
- return toLogical(window.location.pathname, _basePath) + window.location.search;
1412
+ return normalizeHref(toLogical(window.location.pathname, _basePath)) + window.location.search;
1411
1413
  });
1412
1414
  const prefetchCache = useRef(new Map);
1413
1415
  const navVersion = useRef(0);
@@ -1555,7 +1557,7 @@ function RouterProvider({
1555
1557
  window.history.pushState({ _furinKey: generateHistoryKey() }, "", physicalEffective);
1556
1558
  }
1557
1559
  const effectiveUrl = new URL(physicalEffective, window.location.origin);
1558
- const logicalPath = toLogical(effectiveUrl.pathname, _basePath);
1560
+ const logicalPath = normalizeHref(toLogical(effectiveUrl.pathname, _basePath));
1559
1561
  setCurrentHref(logicalPath + effectiveUrl.search);
1560
1562
  if (opts?.resetScroll ?? true) {
1561
1563
  pendingScrollRef.current = { type: "reset", href: physicalEffective };
@@ -1616,7 +1618,7 @@ function RouterProvider({
1616
1618
  if (newState.finalHref) {
1617
1619
  window.history.replaceState(history.state, "", _basePath + effectiveLogical);
1618
1620
  }
1619
- setCurrentHref(effectiveLogical);
1621
+ setCurrentHref(normalizeHref(effectiveLogical));
1620
1622
  if (destKey) {
1621
1623
  pendingScrollRef.current = { type: "restore", key: destKey };
1622
1624
  } else {
@@ -1758,7 +1760,7 @@ function computeLinkView({
1758
1760
  const logicalHrefWithoutHash = buildHref(to, search, undefined);
1759
1761
  const isAbsolute = logicalHref.startsWith("http://") || logicalHref.startsWith("https://") || logicalHref.startsWith("//");
1760
1762
  const href = isAbsolute ? logicalHref : router.basePath + logicalHref;
1761
- const isActive = router.currentHref === logicalHrefWithoutHash;
1763
+ const isActive = !isAbsolute && router.currentHref === normalizeHref(logicalHrefWithoutHash);
1762
1764
  const resolvedChildren = typeof children === "function" ? children({ isActive }) : children;
1763
1765
  const extraProps = {
1764
1766
  ...inactiveProps && !isActive ? inactiveProps() : {},
@@ -1137,7 +1137,7 @@ class MagicString {
1137
1137
  }
1138
1138
 
1139
1139
  // src/plugin/transform-client.ts
1140
- import { parseSync } from "oxc-parser";
1140
+ import { parse } from "yuku-parser";
1141
1141
  var bunTranspiler = new Bun.Transpiler({
1142
1142
  loader: "tsx",
1143
1143
  tsconfig: {
@@ -1288,9 +1288,10 @@ function removeUnusedSpecifiers(s, code, decl, refs) {
1288
1288
  }
1289
1289
  function deadCodeElimination(s) {
1290
1290
  const code = s.toString();
1291
- const { program, errors } = parseSync("dce.js", code);
1292
- if (errors.length > 0) {
1293
- console.error("[furin] DCE: failed to parse transformed output:", errors[0]?.message);
1291
+ const { program, diagnostics } = parse(code, { sourceType: "module" });
1292
+ const firstError = diagnostics.find((d) => d.severity === "error");
1293
+ if (firstError) {
1294
+ console.error("[furin] DCE: failed to parse transformed output:", firstError.message);
1294
1295
  return s;
1295
1296
  }
1296
1297
  const fresh = new MagicString(code);
@@ -1340,9 +1341,10 @@ function removeServerExports(s, source, program) {
1340
1341
  }
1341
1342
  function transformForClient(code, filename) {
1342
1343
  const plainJs = bunTranspiler.transformSync(code);
1343
- const { program, errors } = parseSync(filename, plainJs);
1344
- if (errors.length > 0) {
1345
- throw new Error(`Failed to parse ${filename}: ${errors[0]?.message}`);
1344
+ const { program, diagnostics } = parse(plainJs, { sourceType: "module" });
1345
+ const firstError = diagnostics.find((d) => d.severity === "error");
1346
+ if (firstError) {
1347
+ throw new Error(`Failed to parse ${filename}: ${firstError.message}`);
1346
1348
  }
1347
1349
  let s = new MagicString(plainJs);
1348
1350
  const removedServerCode = removeServerExports(s, plainJs, program);