@lolyjs/core 0.1.0-alpha.3 → 0.1.0-alpha.4
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 +1 -1
- package/dist/cli.js.map +1 -1
- package/dist/index.cjs +25 -12
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +26 -13
- package/dist/index.js.map +1 -1
- package/dist/runtime.cjs +25 -12
- package/dist/runtime.cjs.map +1 -1
- package/dist/runtime.js +26 -13
- package/dist/runtime.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -5094,7 +5094,7 @@ function applyMetadata(md) {
|
|
|
5094
5094
|
}
|
|
5095
5095
|
|
|
5096
5096
|
// modules/runtime/client/AppShell.tsx
|
|
5097
|
-
import { useEffect, useState } from "react";
|
|
5097
|
+
import { useEffect, useState, useRef } from "react";
|
|
5098
5098
|
|
|
5099
5099
|
// modules/runtime/client/RouterView.tsx
|
|
5100
5100
|
import { jsx } from "react/jsx-runtime";
|
|
@@ -5457,14 +5457,19 @@ async function navigate(nextUrl, handlers, options) {
|
|
|
5457
5457
|
}
|
|
5458
5458
|
function createClickHandler(navigate2) {
|
|
5459
5459
|
return function handleClick(ev) {
|
|
5460
|
+
const path25 = ev.composedPath();
|
|
5461
|
+
for (const element of path25) {
|
|
5462
|
+
if (!(element instanceof HTMLElement)) continue;
|
|
5463
|
+
const tagName = element.tagName.toLowerCase();
|
|
5464
|
+
if (tagName === "input" || tagName === "textarea" || tagName === "button" || tagName === "select" || element.isContentEditable || tagName === "label" && element.control) {
|
|
5465
|
+
return;
|
|
5466
|
+
}
|
|
5467
|
+
}
|
|
5468
|
+
const target = ev.target;
|
|
5469
|
+
if (!target) return;
|
|
5460
5470
|
if (ev.defaultPrevented) return;
|
|
5461
5471
|
if (ev.button !== 0) return;
|
|
5462
5472
|
if (ev.metaKey || ev.ctrlKey || ev.shiftKey || ev.altKey) return;
|
|
5463
|
-
const target = ev.target;
|
|
5464
|
-
if (!target) return;
|
|
5465
|
-
const tagName = target.tagName.toLowerCase();
|
|
5466
|
-
const isInteractiveElement = tagName === "input" || tagName === "textarea" || tagName === "button" || tagName === "select" || target.isContentEditable || target.closest("input, textarea, button, select, [contenteditable]");
|
|
5467
|
-
if (isInteractiveElement) return;
|
|
5468
5473
|
const anchor = target.closest("a[href]");
|
|
5469
5474
|
if (!anchor) return;
|
|
5470
5475
|
const href = anchor.getAttribute("href");
|
|
@@ -5498,25 +5503,33 @@ function AppShell({
|
|
|
5498
5503
|
errorRoute
|
|
5499
5504
|
}) {
|
|
5500
5505
|
const [state, setState] = useState(initialState);
|
|
5506
|
+
const handlersRef = useRef({
|
|
5507
|
+
setState,
|
|
5508
|
+
routes,
|
|
5509
|
+
notFoundRoute,
|
|
5510
|
+
errorRoute
|
|
5511
|
+
});
|
|
5501
5512
|
useEffect(() => {
|
|
5502
|
-
|
|
5513
|
+
handlersRef.current = {
|
|
5503
5514
|
setState,
|
|
5504
5515
|
routes,
|
|
5505
5516
|
notFoundRoute,
|
|
5506
5517
|
errorRoute
|
|
5507
5518
|
};
|
|
5519
|
+
}, [routes, notFoundRoute, errorRoute]);
|
|
5520
|
+
useEffect(() => {
|
|
5508
5521
|
async function handleNavigate(nextUrl, options) {
|
|
5509
|
-
await navigate(nextUrl,
|
|
5522
|
+
await navigate(nextUrl, handlersRef.current, options);
|
|
5510
5523
|
}
|
|
5511
5524
|
const handleClick = createClickHandler(handleNavigate);
|
|
5512
5525
|
const handlePopState = createPopStateHandler(handleNavigate);
|
|
5513
|
-
window.addEventListener("click", handleClick);
|
|
5514
|
-
window.addEventListener("popstate", handlePopState);
|
|
5526
|
+
window.addEventListener("click", handleClick, { capture: false });
|
|
5527
|
+
window.addEventListener("popstate", handlePopState, { capture: false });
|
|
5515
5528
|
return () => {
|
|
5516
|
-
window.removeEventListener("click", handleClick);
|
|
5517
|
-
window.removeEventListener("popstate", handlePopState);
|
|
5529
|
+
window.removeEventListener("click", handleClick, { capture: false });
|
|
5530
|
+
window.removeEventListener("popstate", handlePopState, { capture: false });
|
|
5518
5531
|
};
|
|
5519
|
-
}, [
|
|
5532
|
+
}, []);
|
|
5520
5533
|
const isError = state.route === errorRoute;
|
|
5521
5534
|
const isNotFound = state.route === notFoundRoute;
|
|
5522
5535
|
const routeType = isError ? "error" : isNotFound ? "notfound" : "normal";
|