vike-lite-react 1.0.15 → 1.0.16

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.
@@ -2,7 +2,7 @@ import { t as PageContextProvider } from "../../PageContextProvider-DfE3nMiU.mjs
2
2
  import { Component, useCallback, useEffect, useMemo, useRef, useState } from "react";
3
3
  import { createRoot, hydrateRoot } from "react-dom/client";
4
4
  import { matchRoute, stripBase } from "vike-lite/__internal/shared";
5
- import { buildPageContextJsonUrl, createLinkClickHandler, createLinkPrefetchHandler, createRoutePrefetcher, fetchPageContextJson, finalizeNavigation, loadViewModules, tryRecoverFromStaleModuleGraph } from "vike-lite/__internal/client";
5
+ import { buildInitialClientContext, buildPageContextJsonUrl, consumeMatchingInitialContext, createLinkClickHandler, createLinkPrefetchHandler, createRoutePrefetcher, fetchPageContextJson, finalizeNavigation, loadViewModules, resolveHydrationView, tryRecoverFromStaleModuleGraph } from "vike-lite/__internal/client";
6
6
  import { jsx, jsxs } from "react/jsx-runtime";
7
7
  //#region src/__internal/client/onRenderClient.tsx
8
8
  var RootErrorBoundary = class extends Component {
@@ -74,9 +74,8 @@ function RouterApp(props) {
74
74
  useEffect(() => {
75
75
  const pathname = currentPathname;
76
76
  const isReload = reloadTick > 0;
77
- if (!isReload && isFirstRun.current && globalThis.__PAGE_CONTEXT__?.urlPathname === pathname) {
77
+ if (!isReload && isFirstRun.current && consumeMatchingInitialContext(pathname)) {
78
78
  isFirstRun.current = false;
79
- globalThis.__PAGE_CONTEXT__.urlPathname = void 0;
80
79
  return;
81
80
  }
82
81
  isFirstRun.current = false;
@@ -101,7 +100,7 @@ function RouterApp(props) {
101
100
  }));
102
101
  setView(errorView);
103
102
  document.title = is404 ? "Not Found" : "Server Error";
104
- finalizeNavigation(shouldScrollToTop.current);
103
+ finalizeNavigation(shouldScrollToTop);
105
104
  };
106
105
  const loadRoute = async () => {
107
106
  const contextOverride = pendingContextOverride.current;
@@ -148,7 +147,7 @@ function RouterApp(props) {
148
147
  if (globalThis.location.hash) return;
149
148
  document.querySelector("#root")?.focus({ preventScroll: true });
150
149
  });
151
- finalizeNavigation(shouldScrollToTop.current);
150
+ finalizeNavigation(shouldScrollToTop);
152
151
  } catch (error) {
153
152
  if (error.name === "AbortError") return;
154
153
  const message = error.message || "";
@@ -181,22 +180,9 @@ function RouterApp(props) {
181
180
  }
182
181
  async function onRenderClient(clientOptions) {
183
182
  const container = document.querySelector("#root");
184
- const rawContext = globalThis.__PAGE_CONTEXT__ ?? {};
185
183
  const isHydration = clientOptions.hydration && !!globalThis.__PAGE_CONTEXT__;
186
- const initialContext = {
187
- ...rawContext,
188
- isClientSide: true,
189
- isHydration
190
- };
191
- let initialView = {
192
- Page: null,
193
- Layout: null,
194
- Head: null
195
- };
196
- if (isHydration) {
197
- const matched = matchRoute(initialContext.urlPathname ?? globalThis.location.pathname, clientOptions.routes);
198
- if (matched) initialView = await loadViewModules(matched.route);
199
- }
184
+ const initialContext = buildInitialClientContext(globalThis.__PAGE_CONTEXT__, isHydration);
185
+ const initialView = await resolveHydrationView(initialContext, isHydration, clientOptions.routes, clientOptions.errorRoute);
200
186
  const app = /* @__PURE__ */ jsx(RouterApp, {
201
187
  ...clientOptions,
202
188
  initialView,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vike-lite-react",
3
- "version": "1.0.15",
3
+ "version": "1.0.16",
4
4
  "license": "MIT",
5
5
  "repository": {
6
6
  "type": "git",
@@ -56,15 +56,20 @@
56
56
  "build": "tsdown"
57
57
  },
58
58
  "devDependencies": {
59
+ "@testing-library/dom": "^10.4.1",
60
+ "@testing-library/jest-dom": "^6.9.1",
61
+ "@testing-library/react": "^16.3.2",
59
62
  "@types/node": "^26.1.1",
60
63
  "@types/react": "^19.2.17",
61
64
  "@types/react-dom": "^19.2.3",
62
65
  "@vitejs/plugin-react": "^6.0.3",
66
+ "jsdom": "^29.1.1",
63
67
  "react": "^19.2.7",
64
68
  "react-dom": "^19.2.7",
65
69
  "tsdown": "^0.22.9",
66
- "vike-lite": "1.15.13",
67
- "vite": "^8.1.5"
70
+ "vike-lite": "1.15.15",
71
+ "vite": "^8.1.5",
72
+ "vitest": "^4.1.10"
68
73
  },
69
74
  "peerDependencies": {
70
75
  "@vitejs/plugin-react": ">=6",