@unsetsoft/ryunixjs 1.2.4-canary.10 → 1.2.4-canary.11
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/Ryunix.esm.js +22 -11
- package/dist/Ryunix.esm.js.map +1 -1
- package/dist/Ryunix.umd.js +22 -11
- package/dist/Ryunix.umd.js.map +1 -1
- package/dist/Ryunix.umd.min.js +1 -1
- package/dist/Ryunix.umd.min.js.map +1 -1
- package/package.json +1 -1
package/dist/Ryunix.umd.js
CHANGED
|
@@ -562,6 +562,16 @@
|
|
|
562
562
|
*/
|
|
563
563
|
const commitRoot = () => {
|
|
564
564
|
const state = getState();
|
|
565
|
+
|
|
566
|
+
if (state.wipRoot && state.wipRoot.dom && state.wipRoot.dom.hasChildNodes() && !state.currentRoot) {
|
|
567
|
+
// This is the hydration commit. We synchronously clear existing SSR content to prevent FOUC.
|
|
568
|
+
// Ensure we only clear once by verifying !state.currentRoot.
|
|
569
|
+
// We clear BEFORE appending new children in commitWork.
|
|
570
|
+
while (state.wipRoot.dom.firstChild) {
|
|
571
|
+
state.wipRoot.dom.removeChild(state.wipRoot.dom.firstChild);
|
|
572
|
+
}
|
|
573
|
+
}
|
|
574
|
+
|
|
565
575
|
state.deletions.forEach(commitWork);
|
|
566
576
|
commitWork(state.wipRoot.child);
|
|
567
577
|
state.currentRoot = state.wipRoot;
|
|
@@ -1040,7 +1050,10 @@
|
|
|
1040
1050
|
const useQuery = () => {
|
|
1041
1051
|
if (typeof window === 'undefined') return {}
|
|
1042
1052
|
|
|
1043
|
-
const
|
|
1053
|
+
const ctx = RouterContext.useContext('ryunix.navigation');
|
|
1054
|
+
const searchStr = ctx && ctx.location ? (ctx.location.split('?')[1]?.split('#')[0] || '') : window.location.search;
|
|
1055
|
+
|
|
1056
|
+
const searchParams = new URLSearchParams(searchStr || window.location.search);
|
|
1044
1057
|
const query = {};
|
|
1045
1058
|
for (const [key, value] of searchParams.entries()) {
|
|
1046
1059
|
query[key] = value;
|
|
@@ -1059,6 +1072,12 @@
|
|
|
1059
1072
|
const useHash = () => {
|
|
1060
1073
|
if (typeof window === 'undefined') return ''
|
|
1061
1074
|
|
|
1075
|
+
const ctx = RouterContext.useContext('ryunix.navigation');
|
|
1076
|
+
if (ctx && ctx.location) {
|
|
1077
|
+
const parts = ctx.location.split('#');
|
|
1078
|
+
return parts.length > 1 ? `#${parts[1]}` : ''
|
|
1079
|
+
}
|
|
1080
|
+
|
|
1062
1081
|
const [hash, setHash] = useStore(window.location.hash);
|
|
1063
1082
|
useEffect(() => {
|
|
1064
1083
|
const onHashChange = () => setHash(window.location.hash);
|
|
@@ -1185,10 +1204,10 @@
|
|
|
1185
1204
|
* `value` prop set to `contextValue`, and wrapping the `children` within a `Fragment`.
|
|
1186
1205
|
*/
|
|
1187
1206
|
const RouterProvider = ({ routes, children }) => {
|
|
1188
|
-
const [location, setLocation] = useStore(window.location.pathname);
|
|
1207
|
+
const [location, setLocation] = useStore(window.location.pathname + window.location.search + window.location.hash);
|
|
1189
1208
|
|
|
1190
1209
|
useEffect(() => {
|
|
1191
|
-
const update = () => setLocation(window.location.pathname);
|
|
1210
|
+
const update = () => setLocation(window.location.pathname + window.location.search + window.location.hash);
|
|
1192
1211
|
window.addEventListener('popstate', update);
|
|
1193
1212
|
window.addEventListener('hashchange', update);
|
|
1194
1213
|
return () => {
|
|
@@ -1845,15 +1864,7 @@
|
|
|
1845
1864
|
return state.wipRoot
|
|
1846
1865
|
};
|
|
1847
1866
|
|
|
1848
|
-
/**
|
|
1849
|
-
* The `hydrate` function attaches Ryunix elements to an existing HTML DOM.
|
|
1850
|
-
* Note: We clear the SSR content and do a clean CSR render.
|
|
1851
|
-
* The SSR HTML serves its purpose for first-paint and SEO; once JS loads
|
|
1852
|
-
* it takes over with a full CSR render to ensure correctness and interactivity.
|
|
1853
|
-
*/
|
|
1854
1867
|
const hydrate = (element, container) => {
|
|
1855
|
-
// Clear SSR content — prevents duplicate DOM nodes when hooks trigger re-renders
|
|
1856
|
-
clearContainer(container);
|
|
1857
1868
|
return render(element, container)
|
|
1858
1869
|
};
|
|
1859
1870
|
|