@lolyjs/core 0.1.0-alpha.4 → 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/cli.cjs.map +1 -1
- package/dist/cli.js.map +1 -1
- package/dist/index.cjs +146 -31
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +146 -31
- package/dist/index.js.map +1 -1
- package/dist/runtime.cjs +146 -31
- package/dist/runtime.cjs.map +1 -1
- package/dist/runtime.js +146 -31
- package/dist/runtime.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -5499,34 +5499,112 @@ async function navigate(nextUrl, handlers, options) {
|
|
|
5499
5499
|
}
|
|
5500
5500
|
function createClickHandler(navigate2) {
|
|
5501
5501
|
return function handleClick(ev) {
|
|
5502
|
-
const
|
|
5503
|
-
|
|
5504
|
-
|
|
5505
|
-
|
|
5506
|
-
|
|
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
|
+
});
|
|
5513
|
+
try {
|
|
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
|
+
}
|
|
5530
|
+
if (ev.clientX === 0 && ev.clientY === 0 && ev.detail === 0) {
|
|
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 });
|
|
5535
|
+
return;
|
|
5536
|
+
}
|
|
5537
|
+
}
|
|
5538
|
+
}
|
|
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 });
|
|
5546
|
+
return;
|
|
5547
|
+
}
|
|
5548
|
+
const interactiveParent = target.closest("input, textarea, button, select, [contenteditable], label");
|
|
5549
|
+
if (interactiveParent) {
|
|
5550
|
+
if (interactiveParent.tagName.toLowerCase() === "label") {
|
|
5551
|
+
const label = interactiveParent;
|
|
5552
|
+
if (label.control) {
|
|
5553
|
+
console.log("[loly:click] Inside label with control, skipping");
|
|
5554
|
+
return;
|
|
5555
|
+
}
|
|
5556
|
+
} else {
|
|
5557
|
+
console.log("[loly:click] Inside interactive parent, skipping", {
|
|
5558
|
+
parentTag: interactiveParent.tagName.toLowerCase()
|
|
5559
|
+
});
|
|
5560
|
+
return;
|
|
5561
|
+
}
|
|
5562
|
+
}
|
|
5563
|
+
const anchor = target.closest("a[href]");
|
|
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
|
+
});
|
|
5571
|
+
const href = anchor.getAttribute("href");
|
|
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
|
+
}
|
|
5580
|
+
const url = new URL(href, window.location.href);
|
|
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 });
|
|
5507
5587
|
return;
|
|
5508
5588
|
}
|
|
5589
|
+
ev.preventDefault();
|
|
5590
|
+
console.log("[loly:click] Prevented default, navigating");
|
|
5591
|
+
const nextUrl = url.pathname + url.search;
|
|
5592
|
+
const currentUrl = window.location.pathname + window.location.search;
|
|
5593
|
+
if (nextUrl === currentUrl) {
|
|
5594
|
+
console.log("[loly:click] Same URL, skipping", { nextUrl });
|
|
5595
|
+
return;
|
|
5596
|
+
}
|
|
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
|
+
});
|
|
5603
|
+
window.history.pushState({}, "", nextUrl);
|
|
5604
|
+
navigate2(nextUrl, shouldRevalidate ? { revalidate: true } : void 0);
|
|
5605
|
+
} catch (error) {
|
|
5606
|
+
console.error("[loly:click] Error in click handler:", error);
|
|
5509
5607
|
}
|
|
5510
|
-
const target = ev.target;
|
|
5511
|
-
if (!target) return;
|
|
5512
|
-
if (ev.defaultPrevented) return;
|
|
5513
|
-
if (ev.button !== 0) return;
|
|
5514
|
-
if (ev.metaKey || ev.ctrlKey || ev.shiftKey || ev.altKey) return;
|
|
5515
|
-
const anchor = target.closest("a[href]");
|
|
5516
|
-
if (!anchor) return;
|
|
5517
|
-
const href = anchor.getAttribute("href");
|
|
5518
|
-
if (!href) return;
|
|
5519
|
-
if (href.startsWith("#")) return;
|
|
5520
|
-
const url = new URL(href, window.location.href);
|
|
5521
|
-
if (url.origin !== window.location.origin) return;
|
|
5522
|
-
if (anchor.target && anchor.target !== "_self") return;
|
|
5523
|
-
ev.preventDefault();
|
|
5524
|
-
const nextUrl = url.pathname + url.search;
|
|
5525
|
-
const currentUrl = window.location.pathname + window.location.search;
|
|
5526
|
-
if (nextUrl === currentUrl) return;
|
|
5527
|
-
const shouldRevalidate = anchor.hasAttribute("data-revalidate") && anchor.getAttribute("data-revalidate") !== "false";
|
|
5528
|
-
window.history.pushState({}, "", nextUrl);
|
|
5529
|
-
navigate2(nextUrl, shouldRevalidate ? { revalidate: true } : void 0);
|
|
5530
5608
|
};
|
|
5531
5609
|
}
|
|
5532
5610
|
function createPopStateHandler(navigate2) {
|
|
@@ -5560,16 +5638,35 @@ function AppShell({
|
|
|
5560
5638
|
};
|
|
5561
5639
|
}, [routes, notFoundRoute, errorRoute]);
|
|
5562
5640
|
(0, import_react2.useEffect)(() => {
|
|
5641
|
+
console.log("[loly:AppShell] Setting up event listeners");
|
|
5642
|
+
let isMounted = true;
|
|
5643
|
+
let listenerCount = 0;
|
|
5563
5644
|
async function handleNavigate(nextUrl, options) {
|
|
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);
|
|
5564
5650
|
await navigate(nextUrl, handlersRef.current, options);
|
|
5565
5651
|
}
|
|
5566
5652
|
const handleClick = createClickHandler(handleNavigate);
|
|
5567
5653
|
const handlePopState = createPopStateHandler(handleNavigate);
|
|
5568
|
-
window.addEventListener("click", handleClick,
|
|
5569
|
-
window.addEventListener("popstate", handlePopState,
|
|
5654
|
+
window.addEventListener("click", handleClick, false);
|
|
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
|
+
});
|
|
5570
5662
|
return () => {
|
|
5571
|
-
|
|
5572
|
-
|
|
5663
|
+
console.log("[loly:AppShell] Cleaning up event listeners", {
|
|
5664
|
+
wasMounted: isMounted,
|
|
5665
|
+
listenersToRemove: listenerCount
|
|
5666
|
+
});
|
|
5667
|
+
isMounted = false;
|
|
5668
|
+
window.removeEventListener("click", handleClick, false);
|
|
5669
|
+
window.removeEventListener("popstate", handlePopState, false);
|
|
5573
5670
|
};
|
|
5574
5671
|
}, []);
|
|
5575
5672
|
const isError = state.route === errorRoute;
|
|
@@ -5621,14 +5718,25 @@ async function loadInitialRoute(initialUrl, initialData, routes, notFoundRoute,
|
|
|
5621
5718
|
};
|
|
5622
5719
|
}
|
|
5623
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
|
+
});
|
|
5624
5726
|
(async function bootstrap() {
|
|
5625
5727
|
const container = document.getElementById(APP_CONTAINER_ID2);
|
|
5626
5728
|
const initialData = getWindowData();
|
|
5729
|
+
console.log("[loly:runtime] bootstrap starting", {
|
|
5730
|
+
hasContainer: !!container,
|
|
5731
|
+
containerId: APP_CONTAINER_ID2,
|
|
5732
|
+
hasInitialData: !!initialData
|
|
5733
|
+
});
|
|
5627
5734
|
if (!container) {
|
|
5628
|
-
console.error(`Container #${APP_CONTAINER_ID2} not found for hydration`);
|
|
5735
|
+
console.error(`[loly:runtime] Container #${APP_CONTAINER_ID2} not found for hydration`);
|
|
5629
5736
|
return;
|
|
5630
5737
|
}
|
|
5631
5738
|
const initialUrl = window.location.pathname + window.location.search;
|
|
5739
|
+
console.log("[loly:runtime] Loading initial route", { initialUrl });
|
|
5632
5740
|
try {
|
|
5633
5741
|
const initialState = await loadInitialRoute(
|
|
5634
5742
|
initialUrl,
|
|
@@ -5637,9 +5745,15 @@ function bootstrapClient(routes, notFoundRoute, errorRoute = null) {
|
|
|
5637
5745
|
notFoundRoute,
|
|
5638
5746
|
errorRoute
|
|
5639
5747
|
);
|
|
5748
|
+
console.log("[loly:runtime] Initial route loaded", {
|
|
5749
|
+
url: initialState.url,
|
|
5750
|
+
hasRoute: !!initialState.route,
|
|
5751
|
+
hasComponents: !!initialState.components
|
|
5752
|
+
});
|
|
5640
5753
|
if (initialData?.metadata) {
|
|
5641
5754
|
applyMetadata(initialData.metadata);
|
|
5642
5755
|
}
|
|
5756
|
+
console.log("[loly:runtime] Hydrating React app");
|
|
5643
5757
|
(0, import_client5.hydrateRoot)(
|
|
5644
5758
|
container,
|
|
5645
5759
|
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
@@ -5652,9 +5766,10 @@ function bootstrapClient(routes, notFoundRoute, errorRoute = null) {
|
|
|
5652
5766
|
}
|
|
5653
5767
|
)
|
|
5654
5768
|
);
|
|
5769
|
+
console.log("[loly:runtime] React app hydrated successfully");
|
|
5655
5770
|
} catch (error) {
|
|
5656
5771
|
console.error(
|
|
5657
|
-
"[
|
|
5772
|
+
"[loly:runtime] Error loading initial route components for",
|
|
5658
5773
|
initialUrl,
|
|
5659
5774
|
error
|
|
5660
5775
|
);
|