@lolyjs/core 0.1.0-alpha.2 → 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 -9
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +26 -10
- package/dist/index.js.map +1 -1
- package/dist/runtime.cjs +25 -9
- package/dist/runtime.cjs.map +1 -1
- package/dist/runtime.js +26 -10
- 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,11 +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
5473
|
const anchor = target.closest("a[href]");
|
|
5466
5474
|
if (!anchor) return;
|
|
5467
5475
|
const href = anchor.getAttribute("href");
|
|
@@ -5495,25 +5503,33 @@ function AppShell({
|
|
|
5495
5503
|
errorRoute
|
|
5496
5504
|
}) {
|
|
5497
5505
|
const [state, setState] = useState(initialState);
|
|
5506
|
+
const handlersRef = useRef({
|
|
5507
|
+
setState,
|
|
5508
|
+
routes,
|
|
5509
|
+
notFoundRoute,
|
|
5510
|
+
errorRoute
|
|
5511
|
+
});
|
|
5498
5512
|
useEffect(() => {
|
|
5499
|
-
|
|
5513
|
+
handlersRef.current = {
|
|
5500
5514
|
setState,
|
|
5501
5515
|
routes,
|
|
5502
5516
|
notFoundRoute,
|
|
5503
5517
|
errorRoute
|
|
5504
5518
|
};
|
|
5519
|
+
}, [routes, notFoundRoute, errorRoute]);
|
|
5520
|
+
useEffect(() => {
|
|
5505
5521
|
async function handleNavigate(nextUrl, options) {
|
|
5506
|
-
await navigate(nextUrl,
|
|
5522
|
+
await navigate(nextUrl, handlersRef.current, options);
|
|
5507
5523
|
}
|
|
5508
5524
|
const handleClick = createClickHandler(handleNavigate);
|
|
5509
5525
|
const handlePopState = createPopStateHandler(handleNavigate);
|
|
5510
|
-
window.addEventListener("click", handleClick);
|
|
5511
|
-
window.addEventListener("popstate", handlePopState);
|
|
5526
|
+
window.addEventListener("click", handleClick, { capture: false });
|
|
5527
|
+
window.addEventListener("popstate", handlePopState, { capture: false });
|
|
5512
5528
|
return () => {
|
|
5513
|
-
window.removeEventListener("click", handleClick);
|
|
5514
|
-
window.removeEventListener("popstate", handlePopState);
|
|
5529
|
+
window.removeEventListener("click", handleClick, { capture: false });
|
|
5530
|
+
window.removeEventListener("popstate", handlePopState, { capture: false });
|
|
5515
5531
|
};
|
|
5516
|
-
}, [
|
|
5532
|
+
}, []);
|
|
5517
5533
|
const isError = state.route === errorRoute;
|
|
5518
5534
|
const isNotFound = state.route === notFoundRoute;
|
|
5519
5535
|
const routeType = isError ? "error" : isNotFound ? "notfound" : "normal";
|