@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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@akanjs/next",
3
- "version": "0.0.29",
3
+ "version": "0.0.31",
4
4
  "type": "commonjs",
5
5
  "publishConfig": {
6
6
  "access": "public"
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
- ...routeGuide2.children[pathSegment] ?? {},
128
+ ...child ?? {},
127
129
  pathSegment,
128
130
  ...index === pathSegments.length - 1 ? { pathRoute } : {},
129
- children: routeGuide2.children[pathSegment].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__ */ React.createElement(import_client2.csrContext.Provider, { value: csrValues }, location.pathRoute.RootLayouts.reduceRight(
139
+ return /* @__PURE__ */ import_react.default.createElement(import_client2.csrContext.Provider, { value: csrValues }, location.pathRoute.RootLayouts.reduceRight(
138
140
  (children, Layout) => {
139
- return /* @__PURE__ */ React.createElement(Layout, { params: location.params, searchParams: location.searchParams }, children);
141
+ return /* @__PURE__ */ import_react.default.createElement(Layout, { params: location.params, searchParams: location.searchParams }, children);
140
142
  },
141
- /* @__PURE__ */ React.createElement(React.Fragment, null)
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__ */ React.createElement(RouterProvider, null));
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:
@@ -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;