@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/cli.cjs +0 -3
- package/dist/cli.cjs.map +1 -1
- package/dist/cli.js +0 -3
- package/dist/cli.js.map +1 -1
- package/dist/index.cjs +113 -25
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +113 -25
- package/dist/index.js.map +1 -1
- package/dist/runtime.cjs +113 -22
- package/dist/runtime.cjs.map +1 -1
- package/dist/runtime.js +113 -22
- package/dist/runtime.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1353,9 +1353,6 @@ 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
|
-
},
|
|
1359
1356
|
infrastructureLogging: {
|
|
1360
1357
|
level: "error"
|
|
1361
1358
|
},
|
|
@@ -5460,24 +5457,50 @@ async function navigate(nextUrl, handlers, options) {
|
|
|
5460
5457
|
}
|
|
5461
5458
|
function createClickHandler(navigate2) {
|
|
5462
5459
|
return function handleClick(ev) {
|
|
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
|
+
});
|
|
5463
5471
|
try {
|
|
5464
|
-
if (ev.defaultPrevented)
|
|
5465
|
-
|
|
5466
|
-
|
|
5467
|
-
|
|
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
|
+
}
|
|
5468
5488
|
if (ev.clientX === 0 && ev.clientY === 0 && ev.detail === 0) {
|
|
5469
|
-
|
|
5470
|
-
|
|
5471
|
-
|
|
5472
|
-
|
|
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 });
|
|
5473
5493
|
return;
|
|
5474
5494
|
}
|
|
5475
5495
|
}
|
|
5476
5496
|
}
|
|
5477
|
-
|
|
5478
|
-
|
|
5479
|
-
|
|
5480
|
-
|
|
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 });
|
|
5481
5504
|
return;
|
|
5482
5505
|
}
|
|
5483
5506
|
const interactiveParent = target.closest("input, textarea, button, select, [contenteditable], label");
|
|
@@ -5485,29 +5508,60 @@ function createClickHandler(navigate2) {
|
|
|
5485
5508
|
if (interactiveParent.tagName.toLowerCase() === "label") {
|
|
5486
5509
|
const label = interactiveParent;
|
|
5487
5510
|
if (label.control) {
|
|
5511
|
+
console.log("[loly:click] Inside label with control, skipping");
|
|
5488
5512
|
return;
|
|
5489
5513
|
}
|
|
5490
5514
|
} else {
|
|
5515
|
+
console.log("[loly:click] Inside interactive parent, skipping", {
|
|
5516
|
+
parentTag: interactiveParent.tagName.toLowerCase()
|
|
5517
|
+
});
|
|
5491
5518
|
return;
|
|
5492
5519
|
}
|
|
5493
5520
|
}
|
|
5494
5521
|
const anchor = target.closest("a[href]");
|
|
5495
|
-
if (!anchor)
|
|
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
|
+
});
|
|
5496
5529
|
const href = anchor.getAttribute("href");
|
|
5497
|
-
if (!href)
|
|
5498
|
-
|
|
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
|
+
}
|
|
5499
5538
|
const url = new URL(href, window.location.href);
|
|
5500
|
-
if (url.origin !== window.location.origin)
|
|
5501
|
-
|
|
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 });
|
|
5545
|
+
return;
|
|
5546
|
+
}
|
|
5502
5547
|
ev.preventDefault();
|
|
5548
|
+
console.log("[loly:click] Prevented default, navigating");
|
|
5503
5549
|
const nextUrl = url.pathname + url.search;
|
|
5504
5550
|
const currentUrl = window.location.pathname + window.location.search;
|
|
5505
|
-
if (nextUrl === currentUrl)
|
|
5551
|
+
if (nextUrl === currentUrl) {
|
|
5552
|
+
console.log("[loly:click] Same URL, skipping", { nextUrl });
|
|
5553
|
+
return;
|
|
5554
|
+
}
|
|
5506
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
|
+
});
|
|
5507
5561
|
window.history.pushState({}, "", nextUrl);
|
|
5508
5562
|
navigate2(nextUrl, shouldRevalidate ? { revalidate: true } : void 0);
|
|
5509
5563
|
} catch (error) {
|
|
5510
|
-
console.error("[
|
|
5564
|
+
console.error("[loly:click] Error in click handler:", error);
|
|
5511
5565
|
}
|
|
5512
5566
|
};
|
|
5513
5567
|
}
|
|
@@ -5542,16 +5596,32 @@ function AppShell({
|
|
|
5542
5596
|
};
|
|
5543
5597
|
}, [routes, notFoundRoute, errorRoute]);
|
|
5544
5598
|
useEffect(() => {
|
|
5599
|
+
console.log("[loly:AppShell] Setting up event listeners");
|
|
5545
5600
|
let isMounted = true;
|
|
5601
|
+
let listenerCount = 0;
|
|
5546
5602
|
async function handleNavigate(nextUrl, options) {
|
|
5547
|
-
if (!isMounted)
|
|
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);
|
|
5548
5608
|
await navigate(nextUrl, handlersRef.current, options);
|
|
5549
5609
|
}
|
|
5550
5610
|
const handleClick = createClickHandler(handleNavigate);
|
|
5551
5611
|
const handlePopState = createPopStateHandler(handleNavigate);
|
|
5552
5612
|
window.addEventListener("click", handleClick, false);
|
|
5553
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
|
+
});
|
|
5554
5620
|
return () => {
|
|
5621
|
+
console.log("[loly:AppShell] Cleaning up event listeners", {
|
|
5622
|
+
wasMounted: isMounted,
|
|
5623
|
+
listenersToRemove: listenerCount
|
|
5624
|
+
});
|
|
5555
5625
|
isMounted = false;
|
|
5556
5626
|
window.removeEventListener("click", handleClick, false);
|
|
5557
5627
|
window.removeEventListener("popstate", handlePopState, false);
|
|
@@ -5606,14 +5676,25 @@ async function loadInitialRoute(initialUrl, initialData, routes, notFoundRoute,
|
|
|
5606
5676
|
};
|
|
5607
5677
|
}
|
|
5608
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
|
+
});
|
|
5609
5684
|
(async function bootstrap() {
|
|
5610
5685
|
const container = document.getElementById(APP_CONTAINER_ID2);
|
|
5611
5686
|
const initialData = getWindowData();
|
|
5687
|
+
console.log("[loly:runtime] bootstrap starting", {
|
|
5688
|
+
hasContainer: !!container,
|
|
5689
|
+
containerId: APP_CONTAINER_ID2,
|
|
5690
|
+
hasInitialData: !!initialData
|
|
5691
|
+
});
|
|
5612
5692
|
if (!container) {
|
|
5613
|
-
console.error(`Container #${APP_CONTAINER_ID2} not found for hydration`);
|
|
5693
|
+
console.error(`[loly:runtime] Container #${APP_CONTAINER_ID2} not found for hydration`);
|
|
5614
5694
|
return;
|
|
5615
5695
|
}
|
|
5616
5696
|
const initialUrl = window.location.pathname + window.location.search;
|
|
5697
|
+
console.log("[loly:runtime] Loading initial route", { initialUrl });
|
|
5617
5698
|
try {
|
|
5618
5699
|
const initialState = await loadInitialRoute(
|
|
5619
5700
|
initialUrl,
|
|
@@ -5622,9 +5703,15 @@ function bootstrapClient(routes, notFoundRoute, errorRoute = null) {
|
|
|
5622
5703
|
notFoundRoute,
|
|
5623
5704
|
errorRoute
|
|
5624
5705
|
);
|
|
5706
|
+
console.log("[loly:runtime] Initial route loaded", {
|
|
5707
|
+
url: initialState.url,
|
|
5708
|
+
hasRoute: !!initialState.route,
|
|
5709
|
+
hasComponents: !!initialState.components
|
|
5710
|
+
});
|
|
5625
5711
|
if (initialData?.metadata) {
|
|
5626
5712
|
applyMetadata(initialData.metadata);
|
|
5627
5713
|
}
|
|
5714
|
+
console.log("[loly:runtime] Hydrating React app");
|
|
5628
5715
|
hydrateRoot(
|
|
5629
5716
|
container,
|
|
5630
5717
|
/* @__PURE__ */ jsx3(
|
|
@@ -5637,9 +5724,10 @@ function bootstrapClient(routes, notFoundRoute, errorRoute = null) {
|
|
|
5637
5724
|
}
|
|
5638
5725
|
)
|
|
5639
5726
|
);
|
|
5727
|
+
console.log("[loly:runtime] React app hydrated successfully");
|
|
5640
5728
|
} catch (error) {
|
|
5641
5729
|
console.error(
|
|
5642
|
-
"[
|
|
5730
|
+
"[loly:runtime] Error loading initial route components for",
|
|
5643
5731
|
initialUrl,
|
|
5644
5732
|
error
|
|
5645
5733
|
);
|