@lolyjs/core 0.1.0-alpha.5 → 0.1.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.
package/dist/index.cjs CHANGED
@@ -1395,9 +1395,6 @@ function createClientConfig(projectRoot, mode) {
1395
1395
  filename: mode === "production" ? "client.[contenthash].css" : "client.css"
1396
1396
  })
1397
1397
  ],
1398
- externals: {
1399
- "@lolyjs/core/runtime": "@lolyjs/core/runtime"
1400
- },
1401
1398
  infrastructureLogging: {
1402
1399
  level: "error"
1403
1400
  },
@@ -5502,24 +5499,50 @@ async function navigate(nextUrl, handlers, options) {
5502
5499
  }
5503
5500
  function createClickHandler(navigate2) {
5504
5501
  return function handleClick(ev) {
5502
+ const target = ev.target;
5503
+ const tagName = target?.tagName.toLowerCase() || "unknown";
5504
+ console.log("[loly:click] Click event received", {
5505
+ type: ev.type,
5506
+ tagName,
5507
+ target: target?.tagName,
5508
+ defaultPrevented: ev.defaultPrevented,
5509
+ button: ev.button,
5510
+ clientX: ev.clientX,
5511
+ clientY: ev.clientY
5512
+ });
5505
5513
  try {
5506
- if (ev.defaultPrevented) return;
5507
- if (ev.type !== "click") return;
5508
- if (ev.button !== 0) return;
5509
- if (ev.metaKey || ev.ctrlKey || ev.shiftKey || ev.altKey) return;
5514
+ if (ev.defaultPrevented) {
5515
+ console.log("[loly:click] Event already prevented, skipping");
5516
+ return;
5517
+ }
5518
+ if (ev.type !== "click") {
5519
+ console.log("[loly:click] Not a click event, skipping", { type: ev.type });
5520
+ return;
5521
+ }
5522
+ if (ev.button !== 0) {
5523
+ console.log("[loly:click] Not left button, skipping", { button: ev.button });
5524
+ return;
5525
+ }
5526
+ if (ev.metaKey || ev.ctrlKey || ev.shiftKey || ev.altKey) {
5527
+ console.log("[loly:click] Modifier keys pressed, skipping");
5528
+ return;
5529
+ }
5510
5530
  if (ev.clientX === 0 && ev.clientY === 0 && ev.detail === 0) {
5511
- const target2 = ev.target;
5512
- if (target2) {
5513
- const tagName2 = target2.tagName.toLowerCase();
5514
- if (tagName2 === "input" || tagName2 === "textarea" || tagName2 === "button" || tagName2 === "select") {
5531
+ if (target) {
5532
+ const tagName3 = target.tagName.toLowerCase();
5533
+ if (tagName3 === "input" || tagName3 === "textarea" || tagName3 === "button" || tagName3 === "select") {
5534
+ console.log("[loly:click] Synthetic event on interactive element, skipping", { tagName: tagName3 });
5515
5535
  return;
5516
5536
  }
5517
5537
  }
5518
5538
  }
5519
- const target = ev.target;
5520
- if (!target) return;
5521
- const tagName = target.tagName.toLowerCase();
5522
- if (tagName === "input" || tagName === "textarea" || tagName === "button" || tagName === "select" || target.isContentEditable || target.getAttribute("contenteditable") === "true") {
5539
+ if (!target) {
5540
+ console.log("[loly:click] No target, skipping");
5541
+ return;
5542
+ }
5543
+ const tagName2 = target.tagName.toLowerCase();
5544
+ if (tagName2 === "input" || tagName2 === "textarea" || tagName2 === "button" || tagName2 === "select" || target.isContentEditable || target.getAttribute("contenteditable") === "true") {
5545
+ console.log("[loly:click] Target is interactive element, skipping", { tagName: tagName2 });
5523
5546
  return;
5524
5547
  }
5525
5548
  const interactiveParent = target.closest("input, textarea, button, select, [contenteditable], label");
@@ -5527,29 +5550,60 @@ function createClickHandler(navigate2) {
5527
5550
  if (interactiveParent.tagName.toLowerCase() === "label") {
5528
5551
  const label = interactiveParent;
5529
5552
  if (label.control) {
5553
+ console.log("[loly:click] Inside label with control, skipping");
5530
5554
  return;
5531
5555
  }
5532
5556
  } else {
5557
+ console.log("[loly:click] Inside interactive parent, skipping", {
5558
+ parentTag: interactiveParent.tagName.toLowerCase()
5559
+ });
5533
5560
  return;
5534
5561
  }
5535
5562
  }
5536
5563
  const anchor = target.closest("a[href]");
5537
- if (!anchor) return;
5564
+ if (!anchor) {
5565
+ console.log("[loly:click] No anchor found, skipping");
5566
+ return;
5567
+ }
5568
+ console.log("[loly:click] Anchor found, processing navigation", {
5569
+ href: anchor.getAttribute("href")
5570
+ });
5538
5571
  const href = anchor.getAttribute("href");
5539
- if (!href) return;
5540
- if (href.startsWith("#")) return;
5572
+ if (!href) {
5573
+ console.log("[loly:click] No href attribute, skipping");
5574
+ return;
5575
+ }
5576
+ if (href.startsWith("#")) {
5577
+ console.log("[loly:click] Hash link, skipping");
5578
+ return;
5579
+ }
5541
5580
  const url = new URL(href, window.location.href);
5542
- if (url.origin !== window.location.origin) return;
5543
- if (anchor.target && anchor.target !== "_self") return;
5581
+ if (url.origin !== window.location.origin) {
5582
+ console.log("[loly:click] External link, skipping", { origin: url.origin });
5583
+ return;
5584
+ }
5585
+ if (anchor.target && anchor.target !== "_self") {
5586
+ console.log("[loly:click] Link has target, skipping", { target: anchor.target });
5587
+ return;
5588
+ }
5544
5589
  ev.preventDefault();
5590
+ console.log("[loly:click] Prevented default, navigating");
5545
5591
  const nextUrl = url.pathname + url.search;
5546
5592
  const currentUrl = window.location.pathname + window.location.search;
5547
- if (nextUrl === currentUrl) return;
5593
+ if (nextUrl === currentUrl) {
5594
+ console.log("[loly:click] Same URL, skipping", { nextUrl });
5595
+ return;
5596
+ }
5548
5597
  const shouldRevalidate = anchor.hasAttribute("data-revalidate") && anchor.getAttribute("data-revalidate") !== "false";
5598
+ console.log("[loly:click] Pushing state and navigating", {
5599
+ nextUrl,
5600
+ currentUrl,
5601
+ shouldRevalidate
5602
+ });
5549
5603
  window.history.pushState({}, "", nextUrl);
5550
5604
  navigate2(nextUrl, shouldRevalidate ? { revalidate: true } : void 0);
5551
5605
  } catch (error) {
5552
- console.error("[navigation] Error in click handler:", error);
5606
+ console.error("[loly:click] Error in click handler:", error);
5553
5607
  }
5554
5608
  };
5555
5609
  }
@@ -5584,16 +5638,32 @@ function AppShell({
5584
5638
  };
5585
5639
  }, [routes, notFoundRoute, errorRoute]);
5586
5640
  (0, import_react2.useEffect)(() => {
5641
+ console.log("[loly:AppShell] Setting up event listeners");
5587
5642
  let isMounted = true;
5643
+ let listenerCount = 0;
5588
5644
  async function handleNavigate(nextUrl, options) {
5589
- if (!isMounted) return;
5645
+ if (!isMounted) {
5646
+ console.warn("[loly:AppShell] navigate called but component is unmounted");
5647
+ return;
5648
+ }
5649
+ console.log("[loly:AppShell] Navigating to", nextUrl, options);
5590
5650
  await navigate(nextUrl, handlersRef.current, options);
5591
5651
  }
5592
5652
  const handleClick = createClickHandler(handleNavigate);
5593
5653
  const handlePopState = createPopStateHandler(handleNavigate);
5594
5654
  window.addEventListener("click", handleClick, false);
5595
5655
  window.addEventListener("popstate", handlePopState, false);
5656
+ listenerCount = 2;
5657
+ console.log("[loly:AppShell] Event listeners added", {
5658
+ clickListener: true,
5659
+ popStateListener: true,
5660
+ totalListeners: listenerCount
5661
+ });
5596
5662
  return () => {
5663
+ console.log("[loly:AppShell] Cleaning up event listeners", {
5664
+ wasMounted: isMounted,
5665
+ listenersToRemove: listenerCount
5666
+ });
5597
5667
  isMounted = false;
5598
5668
  window.removeEventListener("click", handleClick, false);
5599
5669
  window.removeEventListener("popstate", handlePopState, false);
@@ -5648,14 +5718,25 @@ async function loadInitialRoute(initialUrl, initialData, routes, notFoundRoute,
5648
5718
  };
5649
5719
  }
5650
5720
  function bootstrapClient(routes, notFoundRoute, errorRoute = null) {
5721
+ console.log("[loly:runtime] bootstrapClient called", {
5722
+ routesCount: routes.length,
5723
+ hasNotFound: !!notFoundRoute,
5724
+ hasError: !!errorRoute
5725
+ });
5651
5726
  (async function bootstrap() {
5652
5727
  const container = document.getElementById(APP_CONTAINER_ID2);
5653
5728
  const initialData = getWindowData();
5729
+ console.log("[loly:runtime] bootstrap starting", {
5730
+ hasContainer: !!container,
5731
+ containerId: APP_CONTAINER_ID2,
5732
+ hasInitialData: !!initialData
5733
+ });
5654
5734
  if (!container) {
5655
- console.error(`Container #${APP_CONTAINER_ID2} not found for hydration`);
5735
+ console.error(`[loly:runtime] Container #${APP_CONTAINER_ID2} not found for hydration`);
5656
5736
  return;
5657
5737
  }
5658
5738
  const initialUrl = window.location.pathname + window.location.search;
5739
+ console.log("[loly:runtime] Loading initial route", { initialUrl });
5659
5740
  try {
5660
5741
  const initialState = await loadInitialRoute(
5661
5742
  initialUrl,
@@ -5664,9 +5745,15 @@ function bootstrapClient(routes, notFoundRoute, errorRoute = null) {
5664
5745
  notFoundRoute,
5665
5746
  errorRoute
5666
5747
  );
5748
+ console.log("[loly:runtime] Initial route loaded", {
5749
+ url: initialState.url,
5750
+ hasRoute: !!initialState.route,
5751
+ hasComponents: !!initialState.components
5752
+ });
5667
5753
  if (initialData?.metadata) {
5668
5754
  applyMetadata(initialData.metadata);
5669
5755
  }
5756
+ console.log("[loly:runtime] Hydrating React app");
5670
5757
  (0, import_client5.hydrateRoot)(
5671
5758
  container,
5672
5759
  /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
@@ -5679,9 +5766,10 @@ function bootstrapClient(routes, notFoundRoute, errorRoute = null) {
5679
5766
  }
5680
5767
  )
5681
5768
  );
5769
+ console.log("[loly:runtime] React app hydrated successfully");
5682
5770
  } catch (error) {
5683
5771
  console.error(
5684
- "[client] Error loading initial route components for",
5772
+ "[loly:runtime] Error loading initial route components for",
5685
5773
  initialUrl,
5686
5774
  error
5687
5775
  );