@lolyjs/core 0.2.0-alpha.2 → 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/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.cjs
CHANGED
|
@@ -5138,6 +5138,9 @@ var APP_CONTAINER_ID2 = "__app";
|
|
|
5138
5138
|
|
|
5139
5139
|
// modules/runtime/client/window-data.ts
|
|
5140
5140
|
function getWindowData() {
|
|
5141
|
+
if (typeof window === "undefined") {
|
|
5142
|
+
return null;
|
|
5143
|
+
}
|
|
5141
5144
|
return window[WINDOW_DATA_KEY2] ?? null;
|
|
5142
5145
|
}
|
|
5143
5146
|
function setWindowData(data) {
|
|
@@ -5214,7 +5217,7 @@ function applyMetadata(md) {
|
|
|
5214
5217
|
}
|
|
5215
5218
|
|
|
5216
5219
|
// modules/runtime/client/AppShell.tsx
|
|
5217
|
-
var
|
|
5220
|
+
var import_react3 = require("react");
|
|
5218
5221
|
|
|
5219
5222
|
// modules/runtime/client/RouterView.tsx
|
|
5220
5223
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
@@ -5633,6 +5636,10 @@ function createPopStateHandler(navigate2) {
|
|
|
5633
5636
|
};
|
|
5634
5637
|
}
|
|
5635
5638
|
|
|
5639
|
+
// modules/runtime/client/RouterContext.tsx
|
|
5640
|
+
var import_react2 = require("react");
|
|
5641
|
+
var RouterContext = (0, import_react2.createContext)(null);
|
|
5642
|
+
|
|
5636
5643
|
// modules/runtime/client/AppShell.tsx
|
|
5637
5644
|
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
5638
5645
|
function AppShell({
|
|
@@ -5641,14 +5648,14 @@ function AppShell({
|
|
|
5641
5648
|
notFoundRoute,
|
|
5642
5649
|
errorRoute
|
|
5643
5650
|
}) {
|
|
5644
|
-
const [state, setState] = (0,
|
|
5645
|
-
const handlersRef = (0,
|
|
5651
|
+
const [state, setState] = (0, import_react3.useState)(initialState);
|
|
5652
|
+
const handlersRef = (0, import_react3.useRef)({
|
|
5646
5653
|
setState,
|
|
5647
5654
|
routes,
|
|
5648
5655
|
notFoundRoute,
|
|
5649
5656
|
errorRoute
|
|
5650
5657
|
});
|
|
5651
|
-
(0,
|
|
5658
|
+
(0, import_react3.useEffect)(() => {
|
|
5652
5659
|
handlersRef.current = {
|
|
5653
5660
|
setState,
|
|
5654
5661
|
routes,
|
|
@@ -5656,14 +5663,22 @@ function AppShell({
|
|
|
5656
5663
|
errorRoute
|
|
5657
5664
|
};
|
|
5658
5665
|
}, [routes, notFoundRoute, errorRoute]);
|
|
5659
|
-
(0,
|
|
5666
|
+
const handleNavigate = (0, import_react3.useCallback)(
|
|
5667
|
+
async (nextUrl, options) => {
|
|
5668
|
+
await navigate(nextUrl, handlersRef.current, {
|
|
5669
|
+
revalidate: options?.revalidate
|
|
5670
|
+
});
|
|
5671
|
+
},
|
|
5672
|
+
[]
|
|
5673
|
+
);
|
|
5674
|
+
(0, import_react3.useEffect)(() => {
|
|
5660
5675
|
let isMounted = true;
|
|
5661
|
-
async function
|
|
5676
|
+
async function handleNavigateInternal(nextUrl, options) {
|
|
5662
5677
|
if (!isMounted) return;
|
|
5663
5678
|
await navigate(nextUrl, handlersRef.current, options);
|
|
5664
5679
|
}
|
|
5665
|
-
const handleClick = createClickHandler(
|
|
5666
|
-
const handlePopState = createPopStateHandler(
|
|
5680
|
+
const handleClick = createClickHandler(handleNavigateInternal);
|
|
5681
|
+
const handlePopState = createPopStateHandler(handleNavigateInternal);
|
|
5667
5682
|
window.addEventListener("click", handleClick, false);
|
|
5668
5683
|
window.addEventListener("popstate", handlePopState, false);
|
|
5669
5684
|
return () => {
|
|
@@ -5676,7 +5691,7 @@ function AppShell({
|
|
|
5676
5691
|
const isNotFound = state.route === notFoundRoute;
|
|
5677
5692
|
const routeType = isError ? "error" : isNotFound ? "notfound" : "normal";
|
|
5678
5693
|
const routeKey = `${state.url}:${routeType}`;
|
|
5679
|
-
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(RouterView, { state }, routeKey);
|
|
5694
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(RouterContext.Provider, { value: { navigate: handleNavigate }, children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(RouterView, { state }, routeKey) });
|
|
5680
5695
|
}
|
|
5681
5696
|
|
|
5682
5697
|
// modules/runtime/client/bootstrap.tsx
|