vite-ssg-optimized 0.28.0-optimized.3 → 0.28.0-optimized.4
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/dist/index.mjs +14 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -15,7 +15,20 @@ function ViteSSG(App, routerOptions, fn, options) {
|
|
|
15
15
|
const importMetaEnv = getImportMetaEnv();
|
|
16
16
|
async function createApp$1(routePath) {
|
|
17
17
|
const isClient = !importMetaEnv.SSR;
|
|
18
|
-
|
|
18
|
+
async function detectHydrationMode() {
|
|
19
|
+
if (!isClient) return false;
|
|
20
|
+
return new Promise((resolve) => {
|
|
21
|
+
const fnResolve = () => {
|
|
22
|
+
if (document.readyState !== "loading") {
|
|
23
|
+
resolve(document.querySelectorAll("[data-server-rendered]").length > 0);
|
|
24
|
+
document.removeEventListener("readystatechange", fnResolve);
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
document.addEventListener("readystatechange", fnResolve);
|
|
28
|
+
fnResolve();
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
const isHydrationMode = options?.hydration || await detectHydrationMode();
|
|
19
32
|
const app = isClient && !isHydrationMode ? createApp(App) : createSSRApp(App);
|
|
20
33
|
let head;
|
|
21
34
|
if (useHead) {
|
package/package.json
CHANGED