@unsetsoft/ryunixjs 0.3.7 → 0.3.9-nightly.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 +1 -1
- package/src/lib/hooks.js +25 -1
- package/src/lib/index.js +2 -1
- package/src/lib/navigation.js +1 -1
- package/src/main.js +1 -0
package/package.json
CHANGED
package/src/lib/hooks.js
CHANGED
|
@@ -98,4 +98,28 @@ const useEffect = (effect, deps) => {
|
|
|
98
98
|
vars.hookIndex++;
|
|
99
99
|
};
|
|
100
100
|
|
|
101
|
-
|
|
101
|
+
const useParams = () => {
|
|
102
|
+
vars.hookIndex++;
|
|
103
|
+
|
|
104
|
+
const oldHook =
|
|
105
|
+
vars.wipFiber.alternate &&
|
|
106
|
+
vars.wipFiber.alternate.hooks &&
|
|
107
|
+
vars.wipFiber.alternate.hooks[vars.hookIndex];
|
|
108
|
+
|
|
109
|
+
const hasOld = oldHook ? oldHook : undefined;
|
|
110
|
+
|
|
111
|
+
const urlSearchParams = new URLSearchParams(window.location.search);
|
|
112
|
+
const params = Object.fromEntries(urlSearchParams.entries());
|
|
113
|
+
const Query = hasOld ? hasOld : params;
|
|
114
|
+
|
|
115
|
+
const hook = {
|
|
116
|
+
tag: RYUNIX_TYPES.RYUNIX_EFFECT,
|
|
117
|
+
query: Query,
|
|
118
|
+
};
|
|
119
|
+
|
|
120
|
+
vars.wipFiber.hooks.push(hook);
|
|
121
|
+
|
|
122
|
+
return hook.query;
|
|
123
|
+
};
|
|
124
|
+
|
|
125
|
+
export { useContext, useStore, useEffect, useParams };
|
package/src/lib/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { createElement, Fragments } from "./createElement";
|
|
2
2
|
import { render, init } from "./render";
|
|
3
|
-
import { useContext, useStore, useEffect } from "./hooks";
|
|
3
|
+
import { useContext, useStore, useEffect, useParams } from "./hooks";
|
|
4
4
|
import { createContext } from "./createContext";
|
|
5
5
|
import { Router, Navigate } from "./navigation";
|
|
6
6
|
import * as Dom from "./dom";
|
|
@@ -12,6 +12,7 @@ import * as Commits from "./commits";
|
|
|
12
12
|
export {
|
|
13
13
|
useStore,
|
|
14
14
|
useEffect,
|
|
15
|
+
useParams,
|
|
15
16
|
createContext,
|
|
16
17
|
useContext,
|
|
17
18
|
Fragments,
|
package/src/lib/navigation.js
CHANGED