@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.esm.js
CHANGED
|
@@ -556,6 +556,16 @@ const clearContainer = (container) => {
|
|
|
556
556
|
*/
|
|
557
557
|
const commitRoot = () => {
|
|
558
558
|
const state = getState();
|
|
559
|
+
|
|
560
|
+
if (state.wipRoot && state.wipRoot.dom && state.wipRoot.dom.hasChildNodes() && !state.currentRoot) {
|
|
561
|
+
// This is the hydration commit. We synchronously clear existing SSR content to prevent FOUC.
|
|
562
|
+
// Ensure we only clear once by verifying !state.currentRoot.
|
|
563
|
+
// We clear BEFORE appending new children in commitWork.
|
|
564
|
+
while (state.wipRoot.dom.firstChild) {
|
|
565
|
+
state.wipRoot.dom.removeChild(state.wipRoot.dom.firstChild);
|
|
566
|
+
}
|
|
567
|
+
}
|
|
568
|
+
|
|
559
569
|
state.deletions.forEach(commitWork);
|
|
560
570
|
commitWork(state.wipRoot.child);
|
|
561
571
|
state.currentRoot = state.wipRoot;
|
|
@@ -1034,7 +1044,10 @@ const createContext = (
|
|
|
1034
1044
|
const useQuery = () => {
|
|
1035
1045
|
if (typeof window === 'undefined') return {}
|
|
1036
1046
|
|
|
1037
|
-
const
|
|
1047
|
+
const ctx = RouterContext.useContext('ryunix.navigation');
|
|
1048
|
+
const searchStr = ctx && ctx.location ? (ctx.location.split('?')[1]?.split('#')[0] || '') : window.location.search;
|
|
1049
|
+
|
|
1050
|
+
const searchParams = new URLSearchParams(searchStr || window.location.search);
|
|
1038
1051
|
const query = {};
|
|
1039
1052
|
for (const [key, value] of searchParams.entries()) {
|
|
1040
1053
|
query[key] = value;
|
|
@@ -1053,6 +1066,12 @@ const useQuery = () => {
|
|
|
1053
1066
|
const useHash = () => {
|
|
1054
1067
|
if (typeof window === 'undefined') return ''
|
|
1055
1068
|
|
|
1069
|
+
const ctx = RouterContext.useContext('ryunix.navigation');
|
|
1070
|
+
if (ctx && ctx.location) {
|
|
1071
|
+
const parts = ctx.location.split('#');
|
|
1072
|
+
return parts.length > 1 ? `#${parts[1]}` : ''
|
|
1073
|
+
}
|
|
1074
|
+
|
|
1056
1075
|
const [hash, setHash] = useStore(window.location.hash);
|
|
1057
1076
|
useEffect(() => {
|
|
1058
1077
|
const onHashChange = () => setHash(window.location.hash);
|
|
@@ -1179,10 +1198,10 @@ const findRoute = (routes, path) => {
|
|
|
1179
1198
|
* `value` prop set to `contextValue`, and wrapping the `children` within a `Fragment`.
|
|
1180
1199
|
*/
|
|
1181
1200
|
const RouterProvider = ({ routes, children }) => {
|
|
1182
|
-
const [location, setLocation] = useStore(window.location.pathname);
|
|
1201
|
+
const [location, setLocation] = useStore(window.location.pathname + window.location.search + window.location.hash);
|
|
1183
1202
|
|
|
1184
1203
|
useEffect(() => {
|
|
1185
|
-
const update = () => setLocation(window.location.pathname);
|
|
1204
|
+
const update = () => setLocation(window.location.pathname + window.location.search + window.location.hash);
|
|
1186
1205
|
window.addEventListener('popstate', update);
|
|
1187
1206
|
window.addEventListener('hashchange', update);
|
|
1188
1207
|
return () => {
|
|
@@ -1839,15 +1858,7 @@ const render = (element, container) => {
|
|
|
1839
1858
|
return state.wipRoot
|
|
1840
1859
|
};
|
|
1841
1860
|
|
|
1842
|
-
/**
|
|
1843
|
-
* The `hydrate` function attaches Ryunix elements to an existing HTML DOM.
|
|
1844
|
-
* Note: We clear the SSR content and do a clean CSR render.
|
|
1845
|
-
* The SSR HTML serves its purpose for first-paint and SEO; once JS loads
|
|
1846
|
-
* it takes over with a full CSR render to ensure correctness and interactivity.
|
|
1847
|
-
*/
|
|
1848
1861
|
const hydrate = (element, container) => {
|
|
1849
|
-
// Clear SSR content — prevents duplicate DOM nodes when hooks trigger re-renders
|
|
1850
|
-
clearContainer(container);
|
|
1851
1862
|
return render(element, container)
|
|
1852
1863
|
};
|
|
1853
1864
|
|