@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.js
CHANGED
|
@@ -5457,34 +5457,112 @@ async function navigate(nextUrl, handlers, options) {
|
|
|
5457
5457
|
}
|
|
5458
5458
|
function createClickHandler(navigate2) {
|
|
5459
5459
|
return function handleClick(ev) {
|
|
5460
|
-
const
|
|
5461
|
-
|
|
5462
|
-
|
|
5463
|
-
|
|
5464
|
-
|
|
5460
|
+
const target = ev.target;
|
|
5461
|
+
const tagName = target?.tagName.toLowerCase() || "unknown";
|
|
5462
|
+
console.log("[loly:click] Click event received", {
|
|
5463
|
+
type: ev.type,
|
|
5464
|
+
tagName,
|
|
5465
|
+
target: target?.tagName,
|
|
5466
|
+
defaultPrevented: ev.defaultPrevented,
|
|
5467
|
+
button: ev.button,
|
|
5468
|
+
clientX: ev.clientX,
|
|
5469
|
+
clientY: ev.clientY
|
|
5470
|
+
});
|
|
5471
|
+
try {
|
|
5472
|
+
if (ev.defaultPrevented) {
|
|
5473
|
+
console.log("[loly:click] Event already prevented, skipping");
|
|
5474
|
+
return;
|
|
5475
|
+
}
|
|
5476
|
+
if (ev.type !== "click") {
|
|
5477
|
+
console.log("[loly:click] Not a click event, skipping", { type: ev.type });
|
|
5478
|
+
return;
|
|
5479
|
+
}
|
|
5480
|
+
if (ev.button !== 0) {
|
|
5481
|
+
console.log("[loly:click] Not left button, skipping", { button: ev.button });
|
|
5482
|
+
return;
|
|
5483
|
+
}
|
|
5484
|
+
if (ev.metaKey || ev.ctrlKey || ev.shiftKey || ev.altKey) {
|
|
5485
|
+
console.log("[loly:click] Modifier keys pressed, skipping");
|
|
5486
|
+
return;
|
|
5487
|
+
}
|
|
5488
|
+
if (ev.clientX === 0 && ev.clientY === 0 && ev.detail === 0) {
|
|
5489
|
+
if (target) {
|
|
5490
|
+
const tagName3 = target.tagName.toLowerCase();
|
|
5491
|
+
if (tagName3 === "input" || tagName3 === "textarea" || tagName3 === "button" || tagName3 === "select") {
|
|
5492
|
+
console.log("[loly:click] Synthetic event on interactive element, skipping", { tagName: tagName3 });
|
|
5493
|
+
return;
|
|
5494
|
+
}
|
|
5495
|
+
}
|
|
5496
|
+
}
|
|
5497
|
+
if (!target) {
|
|
5498
|
+
console.log("[loly:click] No target, skipping");
|
|
5499
|
+
return;
|
|
5500
|
+
}
|
|
5501
|
+
const tagName2 = target.tagName.toLowerCase();
|
|
5502
|
+
if (tagName2 === "input" || tagName2 === "textarea" || tagName2 === "button" || tagName2 === "select" || target.isContentEditable || target.getAttribute("contenteditable") === "true") {
|
|
5503
|
+
console.log("[loly:click] Target is interactive element, skipping", { tagName: tagName2 });
|
|
5504
|
+
return;
|
|
5505
|
+
}
|
|
5506
|
+
const interactiveParent = target.closest("input, textarea, button, select, [contenteditable], label");
|
|
5507
|
+
if (interactiveParent) {
|
|
5508
|
+
if (interactiveParent.tagName.toLowerCase() === "label") {
|
|
5509
|
+
const label = interactiveParent;
|
|
5510
|
+
if (label.control) {
|
|
5511
|
+
console.log("[loly:click] Inside label with control, skipping");
|
|
5512
|
+
return;
|
|
5513
|
+
}
|
|
5514
|
+
} else {
|
|
5515
|
+
console.log("[loly:click] Inside interactive parent, skipping", {
|
|
5516
|
+
parentTag: interactiveParent.tagName.toLowerCase()
|
|
5517
|
+
});
|
|
5518
|
+
return;
|
|
5519
|
+
}
|
|
5520
|
+
}
|
|
5521
|
+
const anchor = target.closest("a[href]");
|
|
5522
|
+
if (!anchor) {
|
|
5523
|
+
console.log("[loly:click] No anchor found, skipping");
|
|
5524
|
+
return;
|
|
5525
|
+
}
|
|
5526
|
+
console.log("[loly:click] Anchor found, processing navigation", {
|
|
5527
|
+
href: anchor.getAttribute("href")
|
|
5528
|
+
});
|
|
5529
|
+
const href = anchor.getAttribute("href");
|
|
5530
|
+
if (!href) {
|
|
5531
|
+
console.log("[loly:click] No href attribute, skipping");
|
|
5532
|
+
return;
|
|
5533
|
+
}
|
|
5534
|
+
if (href.startsWith("#")) {
|
|
5535
|
+
console.log("[loly:click] Hash link, skipping");
|
|
5536
|
+
return;
|
|
5537
|
+
}
|
|
5538
|
+
const url = new URL(href, window.location.href);
|
|
5539
|
+
if (url.origin !== window.location.origin) {
|
|
5540
|
+
console.log("[loly:click] External link, skipping", { origin: url.origin });
|
|
5541
|
+
return;
|
|
5542
|
+
}
|
|
5543
|
+
if (anchor.target && anchor.target !== "_self") {
|
|
5544
|
+
console.log("[loly:click] Link has target, skipping", { target: anchor.target });
|
|
5465
5545
|
return;
|
|
5466
5546
|
}
|
|
5547
|
+
ev.preventDefault();
|
|
5548
|
+
console.log("[loly:click] Prevented default, navigating");
|
|
5549
|
+
const nextUrl = url.pathname + url.search;
|
|
5550
|
+
const currentUrl = window.location.pathname + window.location.search;
|
|
5551
|
+
if (nextUrl === currentUrl) {
|
|
5552
|
+
console.log("[loly:click] Same URL, skipping", { nextUrl });
|
|
5553
|
+
return;
|
|
5554
|
+
}
|
|
5555
|
+
const shouldRevalidate = anchor.hasAttribute("data-revalidate") && anchor.getAttribute("data-revalidate") !== "false";
|
|
5556
|
+
console.log("[loly:click] Pushing state and navigating", {
|
|
5557
|
+
nextUrl,
|
|
5558
|
+
currentUrl,
|
|
5559
|
+
shouldRevalidate
|
|
5560
|
+
});
|
|
5561
|
+
window.history.pushState({}, "", nextUrl);
|
|
5562
|
+
navigate2(nextUrl, shouldRevalidate ? { revalidate: true } : void 0);
|
|
5563
|
+
} catch (error) {
|
|
5564
|
+
console.error("[loly:click] Error in click handler:", error);
|
|
5467
5565
|
}
|
|
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
5566
|
};
|
|
5489
5567
|
}
|
|
5490
5568
|
function createPopStateHandler(navigate2) {
|
|
@@ -5518,16 +5596,35 @@ function AppShell({
|
|
|
5518
5596
|
};
|
|
5519
5597
|
}, [routes, notFoundRoute, errorRoute]);
|
|
5520
5598
|
useEffect(() => {
|
|
5599
|
+
console.log("[loly:AppShell] Setting up event listeners");
|
|
5600
|
+
let isMounted = true;
|
|
5601
|
+
let listenerCount = 0;
|
|
5521
5602
|
async function handleNavigate(nextUrl, options) {
|
|
5603
|
+
if (!isMounted) {
|
|
5604
|
+
console.warn("[loly:AppShell] navigate called but component is unmounted");
|
|
5605
|
+
return;
|
|
5606
|
+
}
|
|
5607
|
+
console.log("[loly:AppShell] Navigating to", nextUrl, options);
|
|
5522
5608
|
await navigate(nextUrl, handlersRef.current, options);
|
|
5523
5609
|
}
|
|
5524
5610
|
const handleClick = createClickHandler(handleNavigate);
|
|
5525
5611
|
const handlePopState = createPopStateHandler(handleNavigate);
|
|
5526
|
-
window.addEventListener("click", handleClick,
|
|
5527
|
-
window.addEventListener("popstate", handlePopState,
|
|
5612
|
+
window.addEventListener("click", handleClick, false);
|
|
5613
|
+
window.addEventListener("popstate", handlePopState, false);
|
|
5614
|
+
listenerCount = 2;
|
|
5615
|
+
console.log("[loly:AppShell] Event listeners added", {
|
|
5616
|
+
clickListener: true,
|
|
5617
|
+
popStateListener: true,
|
|
5618
|
+
totalListeners: listenerCount
|
|
5619
|
+
});
|
|
5528
5620
|
return () => {
|
|
5529
|
-
|
|
5530
|
-
|
|
5621
|
+
console.log("[loly:AppShell] Cleaning up event listeners", {
|
|
5622
|
+
wasMounted: isMounted,
|
|
5623
|
+
listenersToRemove: listenerCount
|
|
5624
|
+
});
|
|
5625
|
+
isMounted = false;
|
|
5626
|
+
window.removeEventListener("click", handleClick, false);
|
|
5627
|
+
window.removeEventListener("popstate", handlePopState, false);
|
|
5531
5628
|
};
|
|
5532
5629
|
}, []);
|
|
5533
5630
|
const isError = state.route === errorRoute;
|
|
@@ -5579,14 +5676,25 @@ async function loadInitialRoute(initialUrl, initialData, routes, notFoundRoute,
|
|
|
5579
5676
|
};
|
|
5580
5677
|
}
|
|
5581
5678
|
function bootstrapClient(routes, notFoundRoute, errorRoute = null) {
|
|
5679
|
+
console.log("[loly:runtime] bootstrapClient called", {
|
|
5680
|
+
routesCount: routes.length,
|
|
5681
|
+
hasNotFound: !!notFoundRoute,
|
|
5682
|
+
hasError: !!errorRoute
|
|
5683
|
+
});
|
|
5582
5684
|
(async function bootstrap() {
|
|
5583
5685
|
const container = document.getElementById(APP_CONTAINER_ID2);
|
|
5584
5686
|
const initialData = getWindowData();
|
|
5687
|
+
console.log("[loly:runtime] bootstrap starting", {
|
|
5688
|
+
hasContainer: !!container,
|
|
5689
|
+
containerId: APP_CONTAINER_ID2,
|
|
5690
|
+
hasInitialData: !!initialData
|
|
5691
|
+
});
|
|
5585
5692
|
if (!container) {
|
|
5586
|
-
console.error(`Container #${APP_CONTAINER_ID2} not found for hydration`);
|
|
5693
|
+
console.error(`[loly:runtime] Container #${APP_CONTAINER_ID2} not found for hydration`);
|
|
5587
5694
|
return;
|
|
5588
5695
|
}
|
|
5589
5696
|
const initialUrl = window.location.pathname + window.location.search;
|
|
5697
|
+
console.log("[loly:runtime] Loading initial route", { initialUrl });
|
|
5590
5698
|
try {
|
|
5591
5699
|
const initialState = await loadInitialRoute(
|
|
5592
5700
|
initialUrl,
|
|
@@ -5595,9 +5703,15 @@ function bootstrapClient(routes, notFoundRoute, errorRoute = null) {
|
|
|
5595
5703
|
notFoundRoute,
|
|
5596
5704
|
errorRoute
|
|
5597
5705
|
);
|
|
5706
|
+
console.log("[loly:runtime] Initial route loaded", {
|
|
5707
|
+
url: initialState.url,
|
|
5708
|
+
hasRoute: !!initialState.route,
|
|
5709
|
+
hasComponents: !!initialState.components
|
|
5710
|
+
});
|
|
5598
5711
|
if (initialData?.metadata) {
|
|
5599
5712
|
applyMetadata(initialData.metadata);
|
|
5600
5713
|
}
|
|
5714
|
+
console.log("[loly:runtime] Hydrating React app");
|
|
5601
5715
|
hydrateRoot(
|
|
5602
5716
|
container,
|
|
5603
5717
|
/* @__PURE__ */ jsx3(
|
|
@@ -5610,9 +5724,10 @@ function bootstrapClient(routes, notFoundRoute, errorRoute = null) {
|
|
|
5610
5724
|
}
|
|
5611
5725
|
)
|
|
5612
5726
|
);
|
|
5727
|
+
console.log("[loly:runtime] React app hydrated successfully");
|
|
5613
5728
|
} catch (error) {
|
|
5614
5729
|
console.error(
|
|
5615
|
-
"[
|
|
5730
|
+
"[loly:runtime] Error loading initial route components for",
|
|
5616
5731
|
initialUrl,
|
|
5617
5732
|
error
|
|
5618
5733
|
);
|