@lolyjs/core 0.1.0-alpha.0 → 0.1.0-alpha.10
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/README.md +31 -31
- package/dist/cli.cjs +3 -3
- package/dist/cli.cjs.map +1 -1
- package/dist/cli.js +4 -4
- package/dist/cli.js.map +1 -1
- package/dist/index.cjs +69 -31
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +70 -32
- package/dist/index.js.map +1 -1
- package/dist/runtime.cjs +66 -28
- package/dist/runtime.cjs.map +1 -1
- package/dist/runtime.js +67 -29
- package/dist/runtime.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -711,7 +711,7 @@ function writeClientBoostrapManifest(projectRoot) {
|
|
|
711
711
|
lines.push(` errorRoute,`);
|
|
712
712
|
lines.push(`} from "./routes-client";`);
|
|
713
713
|
lines.push("");
|
|
714
|
-
lines.push(`import { bootstrapClient } from "@
|
|
714
|
+
lines.push(`import { bootstrapClient } from "@lolyjs/core/runtime"`);
|
|
715
715
|
lines.push("");
|
|
716
716
|
lines.push(
|
|
717
717
|
"bootstrapClient(routes as ClientRouteLoaded[], notFoundRoute, errorRoute);"
|
|
@@ -3508,7 +3508,7 @@ function createLogger(options = {}) {
|
|
|
3508
3508
|
const baseConfig = {
|
|
3509
3509
|
level,
|
|
3510
3510
|
base: {
|
|
3511
|
-
name: "@
|
|
3511
|
+
name: "@lolyjs/core",
|
|
3512
3512
|
env: process.env.NODE_ENV || "development"
|
|
3513
3513
|
},
|
|
3514
3514
|
timestamp: import_pino.default.stdTimeFunctions.isoTime,
|
|
@@ -4868,7 +4868,7 @@ async function renderStaticRoute(projectRoot, ssgOutDir, route, urlPath, params)
|
|
|
4868
4868
|
initialData,
|
|
4869
4869
|
meta: loaderResult.metadata,
|
|
4870
4870
|
titleFallback: "My Framework Dev",
|
|
4871
|
-
descriptionFallback: "Static page generated by @
|
|
4871
|
+
descriptionFallback: "Static page generated by @lolyjs/core.",
|
|
4872
4872
|
chunkHref,
|
|
4873
4873
|
clientJsPath,
|
|
4874
4874
|
clientCssPath
|
|
@@ -5457,7 +5457,6 @@ async function navigate(nextUrl, handlers, options) {
|
|
|
5457
5457
|
revalidate: options?.revalidate
|
|
5458
5458
|
});
|
|
5459
5459
|
if (json && json.error) {
|
|
5460
|
-
console.log("[client] Error detected in response:", json);
|
|
5461
5460
|
if (errorRoute) {
|
|
5462
5461
|
const handled = await handleErrorRoute(
|
|
5463
5462
|
nextUrl,
|
|
@@ -5499,26 +5498,54 @@ async function navigate(nextUrl, handlers, options) {
|
|
|
5499
5498
|
}
|
|
5500
5499
|
function createClickHandler(navigate2) {
|
|
5501
5500
|
return function handleClick(ev) {
|
|
5502
|
-
|
|
5503
|
-
|
|
5504
|
-
|
|
5505
|
-
|
|
5506
|
-
|
|
5507
|
-
|
|
5508
|
-
|
|
5509
|
-
|
|
5510
|
-
|
|
5511
|
-
|
|
5512
|
-
|
|
5513
|
-
|
|
5514
|
-
|
|
5515
|
-
|
|
5516
|
-
|
|
5517
|
-
|
|
5518
|
-
|
|
5519
|
-
|
|
5520
|
-
|
|
5521
|
-
|
|
5501
|
+
try {
|
|
5502
|
+
if (ev.defaultPrevented) return;
|
|
5503
|
+
if (ev.type !== "click") return;
|
|
5504
|
+
if (ev.button !== 0) return;
|
|
5505
|
+
if (ev.metaKey || ev.ctrlKey || ev.shiftKey || ev.altKey) return;
|
|
5506
|
+
const target = ev.target;
|
|
5507
|
+
if (ev.clientX === 0 && ev.clientY === 0 && ev.detail === 0) {
|
|
5508
|
+
if (target) {
|
|
5509
|
+
const tagName2 = target.tagName.toLowerCase();
|
|
5510
|
+
if (tagName2 === "input" || tagName2 === "textarea" || tagName2 === "button" || tagName2 === "select") {
|
|
5511
|
+
return;
|
|
5512
|
+
}
|
|
5513
|
+
}
|
|
5514
|
+
}
|
|
5515
|
+
if (!target) return;
|
|
5516
|
+
const tagName = target.tagName.toLowerCase();
|
|
5517
|
+
if (tagName === "input" || tagName === "textarea" || tagName === "button" || tagName === "select" || target.isContentEditable || target.getAttribute("contenteditable") === "true") {
|
|
5518
|
+
return;
|
|
5519
|
+
}
|
|
5520
|
+
const interactiveParent = target.closest("input, textarea, button, select, [contenteditable], label");
|
|
5521
|
+
if (interactiveParent) {
|
|
5522
|
+
if (interactiveParent.tagName.toLowerCase() === "label") {
|
|
5523
|
+
const label = interactiveParent;
|
|
5524
|
+
if (label.control) {
|
|
5525
|
+
return;
|
|
5526
|
+
}
|
|
5527
|
+
} else {
|
|
5528
|
+
return;
|
|
5529
|
+
}
|
|
5530
|
+
}
|
|
5531
|
+
const anchor = target.closest("a[href]");
|
|
5532
|
+
if (!anchor) return;
|
|
5533
|
+
const href = anchor.getAttribute("href");
|
|
5534
|
+
if (!href) return;
|
|
5535
|
+
if (href.startsWith("#")) return;
|
|
5536
|
+
const url = new URL(href, window.location.href);
|
|
5537
|
+
if (url.origin !== window.location.origin) return;
|
|
5538
|
+
if (anchor.target && anchor.target !== "_self") return;
|
|
5539
|
+
ev.preventDefault();
|
|
5540
|
+
const nextUrl = url.pathname + url.search;
|
|
5541
|
+
const currentUrl = window.location.pathname + window.location.search;
|
|
5542
|
+
if (nextUrl === currentUrl) return;
|
|
5543
|
+
const shouldRevalidate = anchor.hasAttribute("data-revalidate") && anchor.getAttribute("data-revalidate") !== "false";
|
|
5544
|
+
window.history.pushState({}, "", nextUrl);
|
|
5545
|
+
navigate2(nextUrl, shouldRevalidate ? { revalidate: true } : void 0);
|
|
5546
|
+
} catch (error) {
|
|
5547
|
+
console.error("[navigation] Error in click handler:", error);
|
|
5548
|
+
}
|
|
5522
5549
|
};
|
|
5523
5550
|
}
|
|
5524
5551
|
function createPopStateHandler(navigate2) {
|
|
@@ -5537,25 +5564,36 @@ function AppShell({
|
|
|
5537
5564
|
errorRoute
|
|
5538
5565
|
}) {
|
|
5539
5566
|
const [state, setState] = (0, import_react2.useState)(initialState);
|
|
5567
|
+
const handlersRef = (0, import_react2.useRef)({
|
|
5568
|
+
setState,
|
|
5569
|
+
routes,
|
|
5570
|
+
notFoundRoute,
|
|
5571
|
+
errorRoute
|
|
5572
|
+
});
|
|
5540
5573
|
(0, import_react2.useEffect)(() => {
|
|
5541
|
-
|
|
5574
|
+
handlersRef.current = {
|
|
5542
5575
|
setState,
|
|
5543
5576
|
routes,
|
|
5544
5577
|
notFoundRoute,
|
|
5545
5578
|
errorRoute
|
|
5546
5579
|
};
|
|
5580
|
+
}, [routes, notFoundRoute, errorRoute]);
|
|
5581
|
+
(0, import_react2.useEffect)(() => {
|
|
5582
|
+
let isMounted = true;
|
|
5547
5583
|
async function handleNavigate(nextUrl, options) {
|
|
5548
|
-
|
|
5584
|
+
if (!isMounted) return;
|
|
5585
|
+
await navigate(nextUrl, handlersRef.current, options);
|
|
5549
5586
|
}
|
|
5550
5587
|
const handleClick = createClickHandler(handleNavigate);
|
|
5551
5588
|
const handlePopState = createPopStateHandler(handleNavigate);
|
|
5552
|
-
window.addEventListener("click", handleClick);
|
|
5553
|
-
window.addEventListener("popstate", handlePopState);
|
|
5589
|
+
window.addEventListener("click", handleClick, false);
|
|
5590
|
+
window.addEventListener("popstate", handlePopState, false);
|
|
5554
5591
|
return () => {
|
|
5555
|
-
|
|
5556
|
-
window.removeEventListener("
|
|
5592
|
+
isMounted = false;
|
|
5593
|
+
window.removeEventListener("click", handleClick, false);
|
|
5594
|
+
window.removeEventListener("popstate", handlePopState, false);
|
|
5557
5595
|
};
|
|
5558
|
-
}, [
|
|
5596
|
+
}, []);
|
|
5559
5597
|
const isError = state.route === errorRoute;
|
|
5560
5598
|
const isNotFound = state.route === notFoundRoute;
|
|
5561
5599
|
const routeType = isError ? "error" : isNotFound ? "notfound" : "normal";
|