@lolyjs/core 0.2.0-alpha.1 → 0.2.0-alpha.3
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/LICENCE.md +9 -0
- package/README.md +12 -0
- package/dist/cli.cjs +5 -1
- package/dist/cli.cjs.map +1 -1
- package/dist/cli.js +5 -1
- package/dist/cli.js.map +1 -1
- package/dist/index.cjs +24 -9
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +20 -5
- package/dist/index.js.map +1 -1
- package/dist/react/hooks.cjs +134 -2
- package/dist/react/hooks.cjs.map +1 -1
- package/dist/react/hooks.d.mts +79 -1
- package/dist/react/hooks.d.ts +79 -1
- package/dist/react/hooks.js +132 -1
- package/dist/react/hooks.js.map +1 -1
- package/dist/runtime.cjs +24 -9
- package/dist/runtime.cjs.map +1 -1
- package/dist/runtime.js +20 -5
- package/dist/runtime.js.map +1 -1
- package/package.json +3 -1
package/dist/index.js
CHANGED
|
@@ -5096,6 +5096,9 @@ var APP_CONTAINER_ID2 = "__app";
|
|
|
5096
5096
|
|
|
5097
5097
|
// modules/runtime/client/window-data.ts
|
|
5098
5098
|
function getWindowData() {
|
|
5099
|
+
if (typeof window === "undefined") {
|
|
5100
|
+
return null;
|
|
5101
|
+
}
|
|
5099
5102
|
return window[WINDOW_DATA_KEY2] ?? null;
|
|
5100
5103
|
}
|
|
5101
5104
|
function setWindowData(data) {
|
|
@@ -5172,7 +5175,7 @@ function applyMetadata(md) {
|
|
|
5172
5175
|
}
|
|
5173
5176
|
|
|
5174
5177
|
// modules/runtime/client/AppShell.tsx
|
|
5175
|
-
import { useEffect, useState, useRef } from "react";
|
|
5178
|
+
import { useEffect, useState, useRef, useCallback } from "react";
|
|
5176
5179
|
|
|
5177
5180
|
// modules/runtime/client/RouterView.tsx
|
|
5178
5181
|
import { jsx } from "react/jsx-runtime";
|
|
@@ -5591,6 +5594,10 @@ function createPopStateHandler(navigate2) {
|
|
|
5591
5594
|
};
|
|
5592
5595
|
}
|
|
5593
5596
|
|
|
5597
|
+
// modules/runtime/client/RouterContext.tsx
|
|
5598
|
+
import { createContext, useContext } from "react";
|
|
5599
|
+
var RouterContext = createContext(null);
|
|
5600
|
+
|
|
5594
5601
|
// modules/runtime/client/AppShell.tsx
|
|
5595
5602
|
import { jsx as jsx2 } from "react/jsx-runtime";
|
|
5596
5603
|
function AppShell({
|
|
@@ -5614,14 +5621,22 @@ function AppShell({
|
|
|
5614
5621
|
errorRoute
|
|
5615
5622
|
};
|
|
5616
5623
|
}, [routes, notFoundRoute, errorRoute]);
|
|
5624
|
+
const handleNavigate = useCallback(
|
|
5625
|
+
async (nextUrl, options) => {
|
|
5626
|
+
await navigate(nextUrl, handlersRef.current, {
|
|
5627
|
+
revalidate: options?.revalidate
|
|
5628
|
+
});
|
|
5629
|
+
},
|
|
5630
|
+
[]
|
|
5631
|
+
);
|
|
5617
5632
|
useEffect(() => {
|
|
5618
5633
|
let isMounted = true;
|
|
5619
|
-
async function
|
|
5634
|
+
async function handleNavigateInternal(nextUrl, options) {
|
|
5620
5635
|
if (!isMounted) return;
|
|
5621
5636
|
await navigate(nextUrl, handlersRef.current, options);
|
|
5622
5637
|
}
|
|
5623
|
-
const handleClick = createClickHandler(
|
|
5624
|
-
const handlePopState = createPopStateHandler(
|
|
5638
|
+
const handleClick = createClickHandler(handleNavigateInternal);
|
|
5639
|
+
const handlePopState = createPopStateHandler(handleNavigateInternal);
|
|
5625
5640
|
window.addEventListener("click", handleClick, false);
|
|
5626
5641
|
window.addEventListener("popstate", handlePopState, false);
|
|
5627
5642
|
return () => {
|
|
@@ -5634,7 +5649,7 @@ function AppShell({
|
|
|
5634
5649
|
const isNotFound = state.route === notFoundRoute;
|
|
5635
5650
|
const routeType = isError ? "error" : isNotFound ? "notfound" : "normal";
|
|
5636
5651
|
const routeKey = `${state.url}:${routeType}`;
|
|
5637
|
-
return /* @__PURE__ */ jsx2(RouterView, { state }, routeKey);
|
|
5652
|
+
return /* @__PURE__ */ jsx2(RouterContext.Provider, { value: { navigate: handleNavigate }, children: /* @__PURE__ */ jsx2(RouterView, { state }, routeKey) });
|
|
5638
5653
|
}
|
|
5639
5654
|
|
|
5640
5655
|
// modules/runtime/client/bootstrap.tsx
|