vike-ripple 0.4.8 → 0.5.0
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
|
@@ -22,6 +22,10 @@ const onRenderClient = async (pageContext) => {
|
|
|
22
22
|
|
|
23
23
|
// ── Build same component tree as SSR ──
|
|
24
24
|
// Apply Layouts (innermost first → outermost last)
|
|
25
|
+
// Children must be tsrx_element(() => Component({})) — NOT tsrx_element(Component).
|
|
26
|
+
// The normal form passes Component as the render function; Ripple's render_tsrx_element
|
|
27
|
+
// calls it with (anchor, block), which Component interprets as props, corrupting block tracking.
|
|
28
|
+
// The () => Component({}) wrapper gives Component the proper props object.
|
|
25
29
|
const Layout = config.Layout ?? config.layout
|
|
26
30
|
const Wrapper = config.Wrapper ?? config.wrapper
|
|
27
31
|
let component = Page
|
|
@@ -30,14 +34,14 @@ const onRenderClient = async (pageContext) => {
|
|
|
30
34
|
for (let i = 0; i < layouts.length; i++) {
|
|
31
35
|
const L = layouts[i]
|
|
32
36
|
const prev = component
|
|
33
|
-
component = (props) => L({ ...props, children: tsrx_element(prev) })
|
|
37
|
+
component = (props) => L({ ...props, children: tsrx_element(() => prev({})) })
|
|
34
38
|
}
|
|
35
39
|
}
|
|
36
40
|
if (Wrapper) {
|
|
37
41
|
const wrappers = Array.isArray(Wrapper) ? Wrapper : [Wrapper]
|
|
38
42
|
for (const W of wrappers) {
|
|
39
43
|
const prev = component
|
|
40
|
-
component = (props) => W({ ...props, children: tsrx_element(prev) })
|
|
44
|
+
component = (props) => W({ ...props, children: tsrx_element(() => prev({})) })
|
|
41
45
|
}
|
|
42
46
|
}
|
|
43
47
|
|
|
@@ -47,22 +51,8 @@ const onRenderClient = async (pageContext) => {
|
|
|
47
51
|
dispose = null
|
|
48
52
|
}
|
|
49
53
|
|
|
50
|
-
//
|
|
51
|
-
|
|
52
|
-
// mount() is the stable fallback when hydration fails (e.g. during HMR reload).
|
|
53
|
-
const { mount, hydrate } = await import('ripple')
|
|
54
|
-
|
|
55
|
-
if (pageContext.isHydration && container.innerHTML !== '') {
|
|
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
|
-
}
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
// mount() clears container internally (target.textContent = '')
|
|
54
|
+
// Always use mount() — hydrate() crashes Ripple's hmr wrapper (hydrate_node is null).
|
|
55
|
+
const { mount } = await import('ripple')
|
|
66
56
|
dispose = mount(component, { target: container, props: {} })
|
|
67
57
|
setHydrated()
|
|
68
58
|
}
|