@lolyjs/core 0.1.0-alpha.4 → 0.1.0-alpha.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1353,6 +1353,9 @@ function createClientConfig(projectRoot, mode) {
1353
1353
  filename: mode === "production" ? "client.[contenthash].css" : "client.css"
1354
1354
  })
1355
1355
  ],
1356
+ externals: {
1357
+ "@lolyjs/core/runtime": "@lolyjs/core/runtime"
1358
+ },
1356
1359
  infrastructureLogging: {
1357
1360
  level: "error"
1358
1361
  },
@@ -5457,34 +5460,55 @@ async function navigate(nextUrl, handlers, options) {
5457
5460
  }
5458
5461
  function createClickHandler(navigate2) {
5459
5462
  return function handleClick(ev) {
5460
- const path25 = ev.composedPath();
5461
- for (const element of path25) {
5462
- if (!(element instanceof HTMLElement)) continue;
5463
- const tagName = element.tagName.toLowerCase();
5464
- if (tagName === "input" || tagName === "textarea" || tagName === "button" || tagName === "select" || element.isContentEditable || tagName === "label" && element.control) {
5463
+ try {
5464
+ if (ev.defaultPrevented) return;
5465
+ if (ev.type !== "click") return;
5466
+ if (ev.button !== 0) return;
5467
+ if (ev.metaKey || ev.ctrlKey || ev.shiftKey || ev.altKey) return;
5468
+ if (ev.clientX === 0 && ev.clientY === 0 && ev.detail === 0) {
5469
+ const target2 = ev.target;
5470
+ if (target2) {
5471
+ const tagName2 = target2.tagName.toLowerCase();
5472
+ if (tagName2 === "input" || tagName2 === "textarea" || tagName2 === "button" || tagName2 === "select") {
5473
+ return;
5474
+ }
5475
+ }
5476
+ }
5477
+ const target = ev.target;
5478
+ if (!target) return;
5479
+ const tagName = target.tagName.toLowerCase();
5480
+ if (tagName === "input" || tagName === "textarea" || tagName === "button" || tagName === "select" || target.isContentEditable || target.getAttribute("contenteditable") === "true") {
5465
5481
  return;
5466
5482
  }
5483
+ const interactiveParent = target.closest("input, textarea, button, select, [contenteditable], label");
5484
+ if (interactiveParent) {
5485
+ if (interactiveParent.tagName.toLowerCase() === "label") {
5486
+ const label = interactiveParent;
5487
+ if (label.control) {
5488
+ return;
5489
+ }
5490
+ } else {
5491
+ return;
5492
+ }
5493
+ }
5494
+ const anchor = target.closest("a[href]");
5495
+ if (!anchor) return;
5496
+ const href = anchor.getAttribute("href");
5497
+ if (!href) return;
5498
+ if (href.startsWith("#")) return;
5499
+ const url = new URL(href, window.location.href);
5500
+ if (url.origin !== window.location.origin) return;
5501
+ if (anchor.target && anchor.target !== "_self") return;
5502
+ ev.preventDefault();
5503
+ const nextUrl = url.pathname + url.search;
5504
+ const currentUrl = window.location.pathname + window.location.search;
5505
+ if (nextUrl === currentUrl) return;
5506
+ const shouldRevalidate = anchor.hasAttribute("data-revalidate") && anchor.getAttribute("data-revalidate") !== "false";
5507
+ window.history.pushState({}, "", nextUrl);
5508
+ navigate2(nextUrl, shouldRevalidate ? { revalidate: true } : void 0);
5509
+ } catch (error) {
5510
+ console.error("[navigation] Error in click handler:", error);
5467
5511
  }
5468
- const target = ev.target;
5469
- if (!target) return;
5470
- if (ev.defaultPrevented) return;
5471
- if (ev.button !== 0) return;
5472
- if (ev.metaKey || ev.ctrlKey || ev.shiftKey || ev.altKey) return;
5473
- const anchor = target.closest("a[href]");
5474
- if (!anchor) return;
5475
- const href = anchor.getAttribute("href");
5476
- if (!href) return;
5477
- if (href.startsWith("#")) return;
5478
- const url = new URL(href, window.location.href);
5479
- if (url.origin !== window.location.origin) return;
5480
- if (anchor.target && anchor.target !== "_self") return;
5481
- ev.preventDefault();
5482
- const nextUrl = url.pathname + url.search;
5483
- const currentUrl = window.location.pathname + window.location.search;
5484
- if (nextUrl === currentUrl) return;
5485
- const shouldRevalidate = anchor.hasAttribute("data-revalidate") && anchor.getAttribute("data-revalidate") !== "false";
5486
- window.history.pushState({}, "", nextUrl);
5487
- navigate2(nextUrl, shouldRevalidate ? { revalidate: true } : void 0);
5488
5512
  };
5489
5513
  }
5490
5514
  function createPopStateHandler(navigate2) {
@@ -5518,16 +5542,19 @@ function AppShell({
5518
5542
  };
5519
5543
  }, [routes, notFoundRoute, errorRoute]);
5520
5544
  useEffect(() => {
5545
+ let isMounted = true;
5521
5546
  async function handleNavigate(nextUrl, options) {
5547
+ if (!isMounted) return;
5522
5548
  await navigate(nextUrl, handlersRef.current, options);
5523
5549
  }
5524
5550
  const handleClick = createClickHandler(handleNavigate);
5525
5551
  const handlePopState = createPopStateHandler(handleNavigate);
5526
- window.addEventListener("click", handleClick, { capture: false });
5527
- window.addEventListener("popstate", handlePopState, { capture: false });
5552
+ window.addEventListener("click", handleClick, false);
5553
+ window.addEventListener("popstate", handlePopState, false);
5528
5554
  return () => {
5529
- window.removeEventListener("click", handleClick, { capture: false });
5530
- window.removeEventListener("popstate", handlePopState, { capture: false });
5555
+ isMounted = false;
5556
+ window.removeEventListener("click", handleClick, false);
5557
+ window.removeEventListener("popstate", handlePopState, false);
5531
5558
  };
5532
5559
  }, []);
5533
5560
  const isError = state.route === errorRoute;