@akanjs/next 0.0.29 → 0.0.31
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/package.json +1 -1
- package/src/bootCsr.js +8 -6
- package/src/useCsrValues.js +1 -1
package/package.json
CHANGED
package/src/bootCsr.js
CHANGED
|
@@ -34,6 +34,7 @@ module.exports = __toCommonJS(bootCsr_exports);
|
|
|
34
34
|
var import_client = require("@akanjs/client");
|
|
35
35
|
var import_client2 = require("@akanjs/client");
|
|
36
36
|
var import_common = require("@akanjs/common");
|
|
37
|
+
var import_react = __toESM(require("react"));
|
|
37
38
|
var ReactDOM = __toESM(require("react-dom/client"));
|
|
38
39
|
var import_useCsrValues = require("./useCsrValues");
|
|
39
40
|
const supportLanguages = ["en", "ko"];
|
|
@@ -122,11 +123,12 @@ const bootCsr = async (context, rootPath, entryPath = "/route") => {
|
|
|
122
123
|
pathRoutes.forEach((pathRoute) => {
|
|
123
124
|
const pathSegments = pathRoute.pathSegments.slice(1);
|
|
124
125
|
pathSegments.reduce((routeGuide2, pathSegment, index) => {
|
|
126
|
+
const child = routeGuide2.children[pathSegment];
|
|
125
127
|
routeGuide2.children[pathSegment] = {
|
|
126
|
-
...
|
|
128
|
+
...child ?? {},
|
|
127
129
|
pathSegment,
|
|
128
130
|
...index === pathSegments.length - 1 ? { pathRoute } : {},
|
|
129
|
-
children:
|
|
131
|
+
children: child?.children ?? {}
|
|
130
132
|
};
|
|
131
133
|
return routeGuide2.children[pathSegment];
|
|
132
134
|
}, routeGuide);
|
|
@@ -134,11 +136,11 @@ const bootCsr = async (context, rootPath, entryPath = "/route") => {
|
|
|
134
136
|
const RouterProvider = () => {
|
|
135
137
|
const csrValues = (0, import_useCsrValues.useCsrValues)(routeGuide, pathRoutes);
|
|
136
138
|
const { location } = csrValues;
|
|
137
|
-
return /* @__PURE__ */
|
|
139
|
+
return /* @__PURE__ */ import_react.default.createElement(import_client2.csrContext.Provider, { value: csrValues }, location.pathRoute.RootLayouts.reduceRight(
|
|
138
140
|
(children, Layout) => {
|
|
139
|
-
return /* @__PURE__ */
|
|
141
|
+
return /* @__PURE__ */ import_react.default.createElement(Layout, { params: location.params, searchParams: location.searchParams }, children);
|
|
140
142
|
},
|
|
141
|
-
/* @__PURE__ */
|
|
143
|
+
/* @__PURE__ */ import_react.default.createElement(import_react.default.Fragment, null)
|
|
142
144
|
));
|
|
143
145
|
};
|
|
144
146
|
if (pathname !== `/${initialPath}`) {
|
|
@@ -149,7 +151,7 @@ const bootCsr = async (context, rootPath, entryPath = "/route") => {
|
|
|
149
151
|
if (!el)
|
|
150
152
|
throw new Error("No root element");
|
|
151
153
|
const root = ReactDOM.createRoot(el);
|
|
152
|
-
root.render(/* @__PURE__ */
|
|
154
|
+
root.render(/* @__PURE__ */ import_react.default.createElement(RouterProvider, null));
|
|
153
155
|
}
|
|
154
156
|
};
|
|
155
157
|
// Annotate the CommonJS export names for ESM import in node:
|
package/src/useCsrValues.js
CHANGED
|
@@ -548,7 +548,7 @@ const useCsrValues = (rootRouteGuide, pathRoutes) => {
|
|
|
548
548
|
}
|
|
549
549
|
};
|
|
550
550
|
window.onpopstate = async (ev) => {
|
|
551
|
-
const routeType = window.location.pathname === getCurrentLocation().pathname ? "forward" : window.location.pathname === getPrevLocation()?.pathname ? "back" : null;
|
|
551
|
+
const routeType = window.location.pathname === getCurrentLocation().pathname && history.current.type !== "back" ? "forward" : window.location.pathname === getPrevLocation()?.pathname ? "back" : null;
|
|
552
552
|
const scrollTop = pageContentRef.current?.scrollTop ?? 0;
|
|
553
553
|
if (!routeType)
|
|
554
554
|
return;
|