@lolyjs/core 0.1.0-alpha.3 → 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/cli.cjs +3 -0
- package/dist/cli.cjs.map +1 -1
- package/dist/cli.js +4 -1
- package/dist/cli.js.map +1 -1
- package/dist/index.cjs +70 -30
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +71 -31
- package/dist/index.js.map +1 -1
- package/dist/runtime.cjs +67 -30
- package/dist/runtime.cjs.map +1 -1
- package/dist/runtime.js +68 -31
- package/dist/runtime.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1395,6 +1395,9 @@ 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
|
+
},
|
|
1398
1401
|
infrastructureLogging: {
|
|
1399
1402
|
level: "error"
|
|
1400
1403
|
},
|
|
@@ -5499,29 +5502,55 @@ async function navigate(nextUrl, handlers, options) {
|
|
|
5499
5502
|
}
|
|
5500
5503
|
function createClickHandler(navigate2) {
|
|
5501
5504
|
return function handleClick(ev) {
|
|
5502
|
-
|
|
5503
|
-
|
|
5504
|
-
|
|
5505
|
-
|
|
5506
|
-
|
|
5507
|
-
|
|
5508
|
-
|
|
5509
|
-
|
|
5510
|
-
|
|
5511
|
-
|
|
5512
|
-
|
|
5513
|
-
|
|
5514
|
-
|
|
5515
|
-
|
|
5516
|
-
|
|
5517
|
-
|
|
5518
|
-
|
|
5519
|
-
|
|
5520
|
-
|
|
5521
|
-
|
|
5522
|
-
|
|
5523
|
-
|
|
5524
|
-
|
|
5505
|
+
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;
|
|
5510
|
+
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") {
|
|
5515
|
+
return;
|
|
5516
|
+
}
|
|
5517
|
+
}
|
|
5518
|
+
}
|
|
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") {
|
|
5523
|
+
return;
|
|
5524
|
+
}
|
|
5525
|
+
const interactiveParent = target.closest("input, textarea, button, select, [contenteditable], label");
|
|
5526
|
+
if (interactiveParent) {
|
|
5527
|
+
if (interactiveParent.tagName.toLowerCase() === "label") {
|
|
5528
|
+
const label = interactiveParent;
|
|
5529
|
+
if (label.control) {
|
|
5530
|
+
return;
|
|
5531
|
+
}
|
|
5532
|
+
} else {
|
|
5533
|
+
return;
|
|
5534
|
+
}
|
|
5535
|
+
}
|
|
5536
|
+
const anchor = target.closest("a[href]");
|
|
5537
|
+
if (!anchor) return;
|
|
5538
|
+
const href = anchor.getAttribute("href");
|
|
5539
|
+
if (!href) return;
|
|
5540
|
+
if (href.startsWith("#")) return;
|
|
5541
|
+
const url = new URL(href, window.location.href);
|
|
5542
|
+
if (url.origin !== window.location.origin) return;
|
|
5543
|
+
if (anchor.target && anchor.target !== "_self") return;
|
|
5544
|
+
ev.preventDefault();
|
|
5545
|
+
const nextUrl = url.pathname + url.search;
|
|
5546
|
+
const currentUrl = window.location.pathname + window.location.search;
|
|
5547
|
+
if (nextUrl === currentUrl) return;
|
|
5548
|
+
const shouldRevalidate = anchor.hasAttribute("data-revalidate") && anchor.getAttribute("data-revalidate") !== "false";
|
|
5549
|
+
window.history.pushState({}, "", nextUrl);
|
|
5550
|
+
navigate2(nextUrl, shouldRevalidate ? { revalidate: true } : void 0);
|
|
5551
|
+
} catch (error) {
|
|
5552
|
+
console.error("[navigation] Error in click handler:", error);
|
|
5553
|
+
}
|
|
5525
5554
|
};
|
|
5526
5555
|
}
|
|
5527
5556
|
function createPopStateHandler(navigate2) {
|
|
@@ -5540,25 +5569,36 @@ function AppShell({
|
|
|
5540
5569
|
errorRoute
|
|
5541
5570
|
}) {
|
|
5542
5571
|
const [state, setState] = (0, import_react2.useState)(initialState);
|
|
5572
|
+
const handlersRef = (0, import_react2.useRef)({
|
|
5573
|
+
setState,
|
|
5574
|
+
routes,
|
|
5575
|
+
notFoundRoute,
|
|
5576
|
+
errorRoute
|
|
5577
|
+
});
|
|
5543
5578
|
(0, import_react2.useEffect)(() => {
|
|
5544
|
-
|
|
5579
|
+
handlersRef.current = {
|
|
5545
5580
|
setState,
|
|
5546
5581
|
routes,
|
|
5547
5582
|
notFoundRoute,
|
|
5548
5583
|
errorRoute
|
|
5549
5584
|
};
|
|
5585
|
+
}, [routes, notFoundRoute, errorRoute]);
|
|
5586
|
+
(0, import_react2.useEffect)(() => {
|
|
5587
|
+
let isMounted = true;
|
|
5550
5588
|
async function handleNavigate(nextUrl, options) {
|
|
5551
|
-
|
|
5589
|
+
if (!isMounted) return;
|
|
5590
|
+
await navigate(nextUrl, handlersRef.current, options);
|
|
5552
5591
|
}
|
|
5553
5592
|
const handleClick = createClickHandler(handleNavigate);
|
|
5554
5593
|
const handlePopState = createPopStateHandler(handleNavigate);
|
|
5555
|
-
window.addEventListener("click", handleClick);
|
|
5556
|
-
window.addEventListener("popstate", handlePopState);
|
|
5594
|
+
window.addEventListener("click", handleClick, false);
|
|
5595
|
+
window.addEventListener("popstate", handlePopState, false);
|
|
5557
5596
|
return () => {
|
|
5558
|
-
|
|
5559
|
-
window.removeEventListener("
|
|
5597
|
+
isMounted = false;
|
|
5598
|
+
window.removeEventListener("click", handleClick, false);
|
|
5599
|
+
window.removeEventListener("popstate", handlePopState, false);
|
|
5560
5600
|
};
|
|
5561
|
-
}, [
|
|
5601
|
+
}, []);
|
|
5562
5602
|
const isError = state.route === errorRoute;
|
|
5563
5603
|
const isNotFound = state.route === notFoundRoute;
|
|
5564
5604
|
const routeType = isError ? "error" : isNotFound ? "notfound" : "normal";
|