vike-ripple 0.4.7 → 0.4.8
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
|
@@ -13,14 +13,6 @@ const tsrx_element = (fn) => ({
|
|
|
13
13
|
let dispose = null
|
|
14
14
|
|
|
15
15
|
const onRenderClient = async (pageContext) => {
|
|
16
|
-
console.log('[vike-ripple] onRenderClient', {
|
|
17
|
-
isHydration: pageContext.isHydration,
|
|
18
|
-
url: pageContext.urlOriginal,
|
|
19
|
-
hasPage: !!pageContext.Page,
|
|
20
|
-
hasLayout: !!pageContext.config?.Layout,
|
|
21
|
-
hasWrapper: !!pageContext.config?.Wrapper,
|
|
22
|
-
})
|
|
23
|
-
|
|
24
16
|
const { Page, config } = pageContext
|
|
25
17
|
if (!Page) return
|
|
26
18
|
|
|
@@ -28,8 +20,6 @@ const onRenderClient = async (pageContext) => {
|
|
|
28
20
|
const container = document.getElementById('root')
|
|
29
21
|
if (!container) return
|
|
30
22
|
|
|
31
|
-
console.log('[vike-ripple] container child count before:', container.childElementCount)
|
|
32
|
-
|
|
33
23
|
// ── Build same component tree as SSR ──
|
|
34
24
|
// Apply Layouts (innermost first → outermost last)
|
|
35
25
|
const Layout = config.Layout ?? config.layout
|
|
@@ -53,21 +43,26 @@ const onRenderClient = async (pageContext) => {
|
|
|
53
43
|
|
|
54
44
|
// ── Clean up previous root ──
|
|
55
45
|
if (dispose) {
|
|
56
|
-
console.log('[vike-ripple] disposing previous root')
|
|
57
46
|
dispose()
|
|
58
47
|
dispose = null
|
|
59
48
|
}
|
|
60
49
|
|
|
61
50
|
// ── Hydrate or mount ──
|
|
51
|
+
// Hydrate preserves SSR HTML; mount clears and re-renders.
|
|
52
|
+
// mount() is the stable fallback when hydration fails (e.g. during HMR reload).
|
|
53
|
+
const { mount, hydrate } = await import('ripple')
|
|
54
|
+
|
|
62
55
|
if (pageContext.isHydration && container.innerHTML !== '') {
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
56
|
+
try {
|
|
57
|
+
dispose = hydrate(component, { target: container, props: {} })
|
|
58
|
+
setHydrated()
|
|
59
|
+
return
|
|
60
|
+
} catch (err) {
|
|
61
|
+
console.warn('[vike-ripple] hydrate failed, falling back to mount:', err)
|
|
62
|
+
}
|
|
70
63
|
}
|
|
64
|
+
|
|
65
|
+
// mount() clears container internally (target.textContent = '')
|
|
66
|
+
dispose = mount(component, { target: container, props: {} })
|
|
71
67
|
setHydrated()
|
|
72
|
-
console.log('[vike-ripple] container child count after:', container.childElementCount)
|
|
73
68
|
}
|