state-in-url 0.1.0 → 0.1.2
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/LICENSE +21 -0
- package/README.md +23 -3
- package/dist/index.js +1 -1
- package/dist/urlstate/useUrlState.d.ts +3 -3
- package/package.json +19 -6
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 asmyshlyaev177
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -8,8 +8,15 @@
|
|
|
8
8
|
<div align="center">
|
|
9
9
|
Seamlessly sync React state with URL query parameters in Next.js/React.js applications. Simplify state management, enhance shareability, and maintain type safety—all through your browser's URL.
|
|
10
10
|
|
|
11
|
+
<a href="https://state-in-url-wine.vercel.app" target="_blank">DEMO</a>
|
|
12
|
+
|
|
13
|
+
|
|
11
14
|
<hr />
|
|
12
15
|
|
|
16
|
+
Add a ⭐️ to support the project!
|
|
17
|
+
|
|
18
|
+
<hr />
|
|
19
|
+
|
|
13
20
|
|
|
14
21
|
[](https://www.linkedin.com/in/asmyshlyaev177/)
|
|
15
22
|
|
|
@@ -19,7 +26,7 @@ Seamlessly sync React state with URL query parameters in Next.js/React.js applic
|
|
|
19
26
|
[](https://github.com/asmyshlyaev177/state-in-url/)
|
|
20
27
|

|
|
21
28
|
|
|
22
|
-
</div>
|
|
29
|
+
</div>
|
|
23
30
|
|
|
24
31
|
# Features
|
|
25
32
|
- **Seamless state synchronization with URL query parameters.**
|
|
@@ -39,6 +46,7 @@ Seamlessly sync React state with URL query parameters in Next.js/React.js applic
|
|
|
39
46
|
- [Contact & Support](#contact--support)
|
|
40
47
|
- [Changelog](#changelog)
|
|
41
48
|
- [License](#license)
|
|
49
|
+
- [Inspiration](#inspiration)
|
|
42
50
|
|
|
43
51
|
## installation
|
|
44
52
|
```sh
|
|
@@ -50,6 +58,13 @@ yarn add state-in-url
|
|
|
50
58
|
pnpm add state-in-url
|
|
51
59
|
```
|
|
52
60
|
|
|
61
|
+
## Run locally
|
|
62
|
+
Clone this repo, run `npm install` and
|
|
63
|
+
```sh
|
|
64
|
+
npm run dev
|
|
65
|
+
```
|
|
66
|
+
Go to [localhost:3000](http://localhost:3000)
|
|
67
|
+
|
|
53
68
|
## useUrlState hook for Next.js
|
|
54
69
|
|
|
55
70
|
`useUrlState` is a custom React hook for Next.js applications that manages state in the URL query string. It allows you to store and retrieve state from the URL search parameters, providing a way to persist state across page reloads and share application state via URLs.
|
|
@@ -200,6 +215,7 @@ const params = new URLSearchParams();
|
|
|
200
215
|
Object.entries(state).forEach(([key, value]) => {
|
|
201
216
|
params.set(key, encode(value));
|
|
202
217
|
});
|
|
218
|
+
const str = params.toString();
|
|
203
219
|
|
|
204
220
|
// from params
|
|
205
221
|
const obj = Object.fromEntries(
|
|
@@ -212,8 +228,7 @@ const obj = Object.fromEntries(
|
|
|
212
228
|
|
|
213
229
|
## Gothas
|
|
214
230
|
|
|
215
|
-
1. Can pass only serializable values, `Function`, `BigInt` or `Symbol` won't work, probably things like `ArrayBuffer` neither.
|
|
216
|
-
2. Developed and tested with recent `Next.js` and `Typescript` versions.
|
|
231
|
+
1. Can pass only serializable values, `Function`, `BigInt` or `Symbol` won't work, probably things like `ArrayBuffer` neither.
|
|
217
232
|
|
|
218
233
|
## Contact & Support
|
|
219
234
|
|
|
@@ -224,3 +239,8 @@ const obj = Object.fromEntries(
|
|
|
224
239
|
|
|
225
240
|
## License
|
|
226
241
|
This project is licensed under the [MIT license](https://github.com/asmyshlyaev177/state-in-url/blob/main/LICENSE).
|
|
242
|
+
|
|
243
|
+
## Inspiration
|
|
244
|
+
[this article](https://www.thisdot.co/blog/communication-between-client-components-in-next-js)
|
|
245
|
+
|
|
246
|
+
[NextJS useSearchParams](https://nextjs.org/docs/app/api-reference/functions/use-search-params)
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import
|
|
1
|
+
import t from"react";import{useRouter as e,usePathname as n,useSearchParams as r}from"next/navigation";const a=t=>{const e=null===t,n=Array.isArray(t),r=t instanceof Date;return(e?"null":r&&"date")||n&&"array"||!e&&!r&&!n&&"object"==typeof t&&"object"||typeof t},c={boolean:"🗵",null:"∙null",undefined:"∙undefined",number:"∓",date:"⏲"};function o(t){switch(a(t)){case"function":case"symbol":return"";case"date":return c.date+t.toISOString();case"string":return encodeURIComponent(t);case"number":return c.number+String(t);case"boolean":return c.boolean+String(t);case"object":case"array":return s(t);case"null":return c.null;case"undefined":return c.undefined;default:return String(t)}}const s=t=>JSON.stringify(t,u).replaceAll('"',"'"),u=(t,e)=>{const n=a(e);return t&&"object"!==n&&"array"!==n?o(e):e},i=t=>t.match(/^∓/)?Number.parseFloat(t.replaceAll("∓","")):t.match(/^🗵/)?!!t.includes("true"):t.match(/^⏲/)?new Date(t.slice(1)):t===c.null?null:t!==c.undefined?decodeURIComponent(t):void 0,l=(t,e)=>t&&"string"==typeof e?i(e):e,f=t=>{let e;try{e=JSON.parse(t,l)}catch{}return e};function d(t){const e=t.replaceAll("'",'"');return f(e)??i(t)}function p(e){const n=t.useCallback((function(t,n){const r=y(n);return"object"===a(t)&&Object.entries(t).forEach((([t,n])=>{const a=e?.[t];JSON.stringify(n)!==JSON.stringify(a)?r.set(t,o(n)):r.delete(t)})),r.toString()}),[e]);return{parse:t.useCallback((function(t){const n=y(t);return{...e,...Object.fromEntries([...n.entries()].map((([t,n])=>[t,d(n)??e?.[t]])))}}),[e]),stringify:n}}const y=t=>new URLSearchParams("string"==typeof t?t:t?.toString?.()||"");function b(a){const c=e(),o=n(),{parse:s,stringify:u}=p(a),i=r(),[l,f]=t.useState((()=>s(i)));t.useEffect((()=>{f((t=>{const e=s(i);return JSON.stringify(t)===JSON.stringify(e)?t:e}))}),[s,i]);const d=t.useCallback((t=>{f("function"==typeof t?e=>t(e):t)}),[]);return{updateUrl:t.useCallback(((t,e)=>{const n=`${o}?${i.toString()}`,r="function"==typeof t?`${o}?${u(t(l))}`:`${o}?${u(t)}`;n!==r&&c.push(r,e)}),[o,c,u,i,l]),updateState:d,state:l}}export{d as decode,o as encode,p as useUrlEncode,b as useUrlState};
|
|
@@ -5,7 +5,7 @@ import { type JSONCompatible } from './utils';
|
|
|
5
5
|
* @param {?JSONCompatible<T>} [defaultState] Optional fallback values for state
|
|
6
6
|
*/
|
|
7
7
|
export declare function useUrlState<T>(defaultState?: JSONCompatible<T>): {
|
|
8
|
-
updateUrl: (value: Readonly<JSONCompatible<T> & {} extends infer T ? { readonly [P in keyof T]: Readonly<(JSONCompatible<T> & {})[P] extends infer T_1 ? { readonly [P_1 in keyof T_1]: Readonly<(JSONCompatible<T> & {})[P][P_1] extends infer T_2 ? { readonly [P_2 in keyof T_2]: Readonly<(JSONCompatible<T> & {})[P][P_1][P_2] extends infer T_3 ? { readonly [P_3 in keyof T_3]: Readonly<(JSONCompatible<T> & {})[P][P_1][P_2][P_3] extends infer T_4 ? { readonly [P_4 in keyof T_4]: Readonly<(JSONCompatible<T> & {})[P][P_1][P_2][P_3][P_4] extends infer T_5 ? { readonly [P_5 in keyof T_5]: Readonly<(JSONCompatible<T> & {})[P][P_1][P_2][P_3][P_4][P_5] extends infer T_6 ? { readonly [P_6 in keyof T_6]: Readonly<(JSONCompatible<T> & {})[P][P_1][P_2][P_3][P_4][P_5][P_6] extends infer T_7 ? { readonly [P_7 in keyof T_7]: Readonly<(JSONCompatible<T> & {})[P][P_1][P_2][P_3][P_4][P_5][P_6][P_7] extends infer T_8 ? { readonly [P_8 in keyof T_8]: Readonly<(JSONCompatible<T> & {})[P][P_1][P_2][P_3][P_4][P_5][P_6][P_7][P_8] extends infer T_9 ? { readonly [P_9 in keyof T_9]: Readonly<(JSONCompatible<T> & {})[P][P_1][P_2][P_3][P_4][P_5][P_6][P_7][P_8][P_9] extends infer T_10 ? { readonly [P_10 in keyof T_10]: Readonly<any>; } : never>; } : never>; } : never>; } : never>; } : never>; } : never>; } : never>; } : never>; } : never>; } : never>; } : never> | ((currState: Readonly<JSONCompatible<T> & {} extends infer T ? { readonly [P in keyof T]: Readonly<(JSONCompatible<T> & {})[P] extends infer T_1 ? { readonly [P_1 in keyof T_1]: Readonly<(JSONCompatible<T> & {})[P][P_1] extends infer T_2 ? { readonly [P_2 in keyof T_2]: Readonly<(JSONCompatible<T> & {})[P][P_1][P_2] extends infer T_3 ? { readonly [P_3 in keyof T_3]: Readonly<(JSONCompatible<T> & {})[P][P_1][P_2][P_3] extends infer T_4 ? { readonly [P_4 in keyof T_4]: Readonly<(JSONCompatible<T> & {})[P][P_1][P_2][P_3][P_4] extends infer T_5 ? { readonly [P_5 in keyof T_5]: Readonly<(JSONCompatible<T> & {})[P][P_1][P_2][P_3][P_4][P_5] extends infer T_6 ? { readonly [P_6 in keyof T_6]: Readonly<(JSONCompatible<T> & {})[P][P_1][P_2][P_3][P_4][P_5][P_6] extends infer T_7 ? { readonly [P_7 in keyof T_7]: Readonly<(JSONCompatible<T> & {})[P][P_1][P_2][P_3][P_4][P_5][P_6][P_7] extends infer T_8 ? { readonly [P_8 in keyof T_8]: Readonly<(JSONCompatible<T> & {})[P][P_1][P_2][P_3][P_4][P_5][P_6][P_7][P_8] extends infer T_9 ? { readonly [P_9 in keyof T_9]: Readonly<(JSONCompatible<T> & {})[P][P_1][P_2][P_3][P_4][P_5][P_6][P_7][P_8][P_9] extends infer T_10 ? { readonly [P_10 in keyof T_10]: Readonly<any>; } : never>; } : never>; } : never>; } : never>; } : never>; } : never>; } : never>; } : never>; } : never>; } : never>; } : never>) => Readonly<JSONCompatible<T> & {} extends infer T ? { readonly [P in keyof T]: Readonly<(JSONCompatible<T> & {})[P] extends infer T_1 ? { readonly [P_1 in keyof T_1]: Readonly<(JSONCompatible<T> & {})[P][P_1] extends infer T_2 ? { readonly [P_2 in keyof T_2]: Readonly<(JSONCompatible<T> & {})[P][P_1][P_2] extends infer T_3 ? { readonly [P_3 in keyof T_3]: Readonly<(JSONCompatible<T> & {})[P][P_1][P_2][P_3] extends infer T_4 ? { readonly [P_4 in keyof T_4]: Readonly<(JSONCompatible<T> & {})[P][P_1][P_2][P_3][P_4] extends infer T_5 ? { readonly [P_5 in keyof T_5]: Readonly<(JSONCompatible<T> & {})[P][P_1][P_2][P_3][P_4][P_5] extends infer T_6 ? { readonly [P_6 in keyof T_6]: Readonly<(JSONCompatible<T> & {})[P][P_1][P_2][P_3][P_4][P_5][P_6] extends infer T_7 ? { readonly [P_7 in keyof T_7]: Readonly<(JSONCompatible<T> & {})[P][P_1][P_2][P_3][P_4][P_5][P_6][P_7] extends infer T_8 ? { readonly [P_8 in keyof T_8]: Readonly<(JSONCompatible<T> & {})[P][P_1][P_2][P_3][P_4][P_5][P_6][P_7][P_8] extends infer T_9 ? { readonly [P_9 in keyof T_9]: Readonly<(JSONCompatible<T> & {})[P][P_1][P_2][P_3][P_4][P_5][P_6][P_7][P_8][P_9] extends infer T_10 ? { readonly [P_10 in keyof T_10]: Readonly<any>; } : never>; } : never>; } : never>; } : never>; } : never>; } : never>; } : never>; } : never>; } : never>; } : never>; } : never>)) => void;
|
|
9
|
-
updateState: (value: Readonly<JSONCompatible<T> & {} extends infer T_11 ? { readonly [P in keyof T_11]: Readonly<(JSONCompatible<T> & {})[P] extends infer T_12 ? { readonly [P_1 in keyof T_12]: Readonly<(JSONCompatible<T> & {})[P][P_1] extends infer T_13 ? { readonly [P_2 in keyof T_13]: Readonly<(JSONCompatible<T> & {})[P][P_1][P_2] extends infer T_14 ? { readonly [P_3 in keyof T_14]: Readonly<(JSONCompatible<T> & {})[P][P_1][P_2][P_3] extends infer T_15 ? { readonly [P_4 in keyof T_15]: Readonly<(JSONCompatible<T> & {})[P][P_1][P_2][P_3][P_4] extends infer T_16 ? { readonly [P_5 in keyof T_16]: Readonly<(JSONCompatible<T> & {})[P][P_1][P_2][P_3][P_4][P_5] extends infer T_17 ? { readonly [P_6 in keyof T_17]: Readonly<(JSONCompatible<T> & {})[P][P_1][P_2][P_3][P_4][P_5][P_6] extends infer T_18 ? { readonly [P_7 in keyof T_18]: Readonly<(JSONCompatible<T> & {})[P][P_1][P_2][P_3][P_4][P_5][P_6][P_7] extends infer T_19 ? { readonly [P_8 in keyof T_19]: Readonly<(JSONCompatible<T> & {})[P][P_1][P_2][P_3][P_4][P_5][P_6][P_7][P_8] extends infer T_20 ? { readonly [P_9 in keyof T_20]: Readonly<(JSONCompatible<T> & {})[P][P_1][P_2][P_3][P_4][P_5][P_6][P_7][P_8][P_9] extends infer T_21 ? { readonly [P_10 in keyof T_21]: Readonly<any>; } : never>; } : never>; } : never>; } : never>; } : never>; } : never>; } : never>; } : never>; } : never>; } : never>; } : never> | ((currState: Readonly<JSONCompatible<T> & {} extends infer
|
|
10
|
-
state: Readonly<JSONCompatible<T> & {} extends infer
|
|
8
|
+
updateUrl: (value: Readonly<JSONCompatible<T> & {} extends infer T ? { readonly [P in keyof T]: Readonly<(JSONCompatible<T> & {})[P] extends infer T_1 ? { readonly [P_1 in keyof T_1]: Readonly<(JSONCompatible<T> & {})[P][P_1] extends infer T_2 ? { readonly [P_2 in keyof T_2]: Readonly<(JSONCompatible<T> & {})[P][P_1][P_2] extends infer T_3 ? { readonly [P_3 in keyof T_3]: Readonly<(JSONCompatible<T> & {})[P][P_1][P_2][P_3] extends infer T_4 ? { readonly [P_4 in keyof T_4]: Readonly<(JSONCompatible<T> & {})[P][P_1][P_2][P_3][P_4] extends infer T_5 ? { readonly [P_5 in keyof T_5]: Readonly<(JSONCompatible<T> & {})[P][P_1][P_2][P_3][P_4][P_5] extends infer T_6 ? { readonly [P_6 in keyof T_6]: Readonly<(JSONCompatible<T> & {})[P][P_1][P_2][P_3][P_4][P_5][P_6] extends infer T_7 ? { readonly [P_7 in keyof T_7]: Readonly<(JSONCompatible<T> & {})[P][P_1][P_2][P_3][P_4][P_5][P_6][P_7] extends infer T_8 ? { readonly [P_8 in keyof T_8]: Readonly<(JSONCompatible<T> & {})[P][P_1][P_2][P_3][P_4][P_5][P_6][P_7][P_8] extends infer T_9 ? { readonly [P_9 in keyof T_9]: Readonly<(JSONCompatible<T> & {})[P][P_1][P_2][P_3][P_4][P_5][P_6][P_7][P_8][P_9] extends infer T_10 ? { readonly [P_10 in keyof T_10]: Readonly<any>; } : never>; } : never>; } : never>; } : never>; } : never>; } : never>; } : never>; } : never>; } : never>; } : never>; } : never> | ((currState: Readonly<JSONCompatible<T> & {} extends infer T ? { readonly [P in keyof T]: Readonly<(JSONCompatible<T> & {})[P] extends infer T_1 ? { readonly [P_1 in keyof T_1]: Readonly<(JSONCompatible<T> & {})[P][P_1] extends infer T_2 ? { readonly [P_2 in keyof T_2]: Readonly<(JSONCompatible<T> & {})[P][P_1][P_2] extends infer T_3 ? { readonly [P_3 in keyof T_3]: Readonly<(JSONCompatible<T> & {})[P][P_1][P_2][P_3] extends infer T_4 ? { readonly [P_4 in keyof T_4]: Readonly<(JSONCompatible<T> & {})[P][P_1][P_2][P_3][P_4] extends infer T_5 ? { readonly [P_5 in keyof T_5]: Readonly<(JSONCompatible<T> & {})[P][P_1][P_2][P_3][P_4][P_5] extends infer T_6 ? { readonly [P_6 in keyof T_6]: Readonly<(JSONCompatible<T> & {})[P][P_1][P_2][P_3][P_4][P_5][P_6] extends infer T_7 ? { readonly [P_7 in keyof T_7]: Readonly<(JSONCompatible<T> & {})[P][P_1][P_2][P_3][P_4][P_5][P_6][P_7] extends infer T_8 ? { readonly [P_8 in keyof T_8]: Readonly<(JSONCompatible<T> & {})[P][P_1][P_2][P_3][P_4][P_5][P_6][P_7][P_8] extends infer T_9 ? { readonly [P_9 in keyof T_9]: Readonly<(JSONCompatible<T> & {})[P][P_1][P_2][P_3][P_4][P_5][P_6][P_7][P_8][P_9] extends infer T_10 ? { readonly [P_10 in keyof T_10]: Readonly<any>; } : never>; } : never>; } : never>; } : never>; } : never>; } : never>; } : never>; } : never>; } : never>; } : never>; } : never>) => Readonly<JSONCompatible<T> & {} extends infer T ? { readonly [P in keyof T]: Readonly<(JSONCompatible<T> & {})[P] extends infer T_1 ? { readonly [P_1 in keyof T_1]: Readonly<(JSONCompatible<T> & {})[P][P_1] extends infer T_2 ? { readonly [P_2 in keyof T_2]: Readonly<(JSONCompatible<T> & {})[P][P_1][P_2] extends infer T_3 ? { readonly [P_3 in keyof T_3]: Readonly<(JSONCompatible<T> & {})[P][P_1][P_2][P_3] extends infer T_4 ? { readonly [P_4 in keyof T_4]: Readonly<(JSONCompatible<T> & {})[P][P_1][P_2][P_3][P_4] extends infer T_5 ? { readonly [P_5 in keyof T_5]: Readonly<(JSONCompatible<T> & {})[P][P_1][P_2][P_3][P_4][P_5] extends infer T_6 ? { readonly [P_6 in keyof T_6]: Readonly<(JSONCompatible<T> & {})[P][P_1][P_2][P_3][P_4][P_5][P_6] extends infer T_7 ? { readonly [P_7 in keyof T_7]: Readonly<(JSONCompatible<T> & {})[P][P_1][P_2][P_3][P_4][P_5][P_6][P_7] extends infer T_8 ? { readonly [P_8 in keyof T_8]: Readonly<(JSONCompatible<T> & {})[P][P_1][P_2][P_3][P_4][P_5][P_6][P_7][P_8] extends infer T_9 ? { readonly [P_9 in keyof T_9]: Readonly<(JSONCompatible<T> & {})[P][P_1][P_2][P_3][P_4][P_5][P_6][P_7][P_8][P_9] extends infer T_10 ? { readonly [P_10 in keyof T_10]: Readonly<any>; } : never>; } : never>; } : never>; } : never>; } : never>; } : never>; } : never>; } : never>; } : never>; } : never>; } : never>), options?: import("next/dist/shared/lib/app-router-context.shared-runtime").NavigateOptions | undefined) => void;
|
|
9
|
+
updateState: (value: Readonly<JSONCompatible<T> & {} extends infer T_11 ? { readonly [P in keyof T_11]: Readonly<(JSONCompatible<T> & {})[P] extends infer T_12 ? { readonly [P_1 in keyof T_12]: Readonly<(JSONCompatible<T> & {})[P][P_1] extends infer T_13 ? { readonly [P_2 in keyof T_13]: Readonly<(JSONCompatible<T> & {})[P][P_1][P_2] extends infer T_14 ? { readonly [P_3 in keyof T_14]: Readonly<(JSONCompatible<T> & {})[P][P_1][P_2][P_3] extends infer T_15 ? { readonly [P_4 in keyof T_15]: Readonly<(JSONCompatible<T> & {})[P][P_1][P_2][P_3][P_4] extends infer T_16 ? { readonly [P_5 in keyof T_16]: Readonly<(JSONCompatible<T> & {})[P][P_1][P_2][P_3][P_4][P_5] extends infer T_17 ? { readonly [P_6 in keyof T_17]: Readonly<(JSONCompatible<T> & {})[P][P_1][P_2][P_3][P_4][P_5][P_6] extends infer T_18 ? { readonly [P_7 in keyof T_18]: Readonly<(JSONCompatible<T> & {})[P][P_1][P_2][P_3][P_4][P_5][P_6][P_7] extends infer T_19 ? { readonly [P_8 in keyof T_19]: Readonly<(JSONCompatible<T> & {})[P][P_1][P_2][P_3][P_4][P_5][P_6][P_7][P_8] extends infer T_20 ? { readonly [P_9 in keyof T_20]: Readonly<(JSONCompatible<T> & {})[P][P_1][P_2][P_3][P_4][P_5][P_6][P_7][P_8][P_9] extends infer T_21 ? { readonly [P_10 in keyof T_21]: Readonly<any>; } : never>; } : never>; } : never>; } : never>; } : never>; } : never>; } : never>; } : never>; } : never>; } : never>; } : never> | ((currState: Readonly<JSONCompatible<T> & {} extends infer T_22 ? { readonly [P in keyof T_22]: Readonly<(JSONCompatible<T> & {})[P] extends infer T_23 ? { readonly [P_1 in keyof T_23]: Readonly<(JSONCompatible<T> & {})[P][P_1] extends infer T_24 ? { readonly [P_2 in keyof T_24]: Readonly<(JSONCompatible<T> & {})[P][P_1][P_2] extends infer T_25 ? { readonly [P_3 in keyof T_25]: Readonly<(JSONCompatible<T> & {})[P][P_1][P_2][P_3] extends infer T_26 ? { readonly [P_4 in keyof T_26]: Readonly<(JSONCompatible<T> & {})[P][P_1][P_2][P_3][P_4] extends infer T_27 ? { readonly [P_5 in keyof T_27]: Readonly<(JSONCompatible<T> & {})[P][P_1][P_2][P_3][P_4][P_5] extends infer T_28 ? { readonly [P_6 in keyof T_28]: Readonly<(JSONCompatible<T> & {})[P][P_1][P_2][P_3][P_4][P_5][P_6] extends infer T_29 ? { readonly [P_7 in keyof T_29]: Readonly<(JSONCompatible<T> & {})[P][P_1][P_2][P_3][P_4][P_5][P_6][P_7] extends infer T_30 ? { readonly [P_8 in keyof T_30]: Readonly<(JSONCompatible<T> & {})[P][P_1][P_2][P_3][P_4][P_5][P_6][P_7][P_8] extends infer T_31 ? { readonly [P_9 in keyof T_31]: Readonly<(JSONCompatible<T> & {})[P][P_1][P_2][P_3][P_4][P_5][P_6][P_7][P_8][P_9] extends infer T_32 ? { readonly [P_10 in keyof T_32]: Readonly<any>; } : never>; } : never>; } : never>; } : never>; } : never>; } : never>; } : never>; } : never>; } : never>; } : never>; } : never>) => Readonly<JSONCompatible<T> & {} extends infer T_33 ? { readonly [P in keyof T_33]: Readonly<(JSONCompatible<T> & {})[P] extends infer T_34 ? { readonly [P_1 in keyof T_34]: Readonly<(JSONCompatible<T> & {})[P][P_1] extends infer T_35 ? { readonly [P_2 in keyof T_35]: Readonly<(JSONCompatible<T> & {})[P][P_1][P_2] extends infer T_36 ? { readonly [P_3 in keyof T_36]: Readonly<(JSONCompatible<T> & {})[P][P_1][P_2][P_3] extends infer T_37 ? { readonly [P_4 in keyof T_37]: Readonly<(JSONCompatible<T> & {})[P][P_1][P_2][P_3][P_4] extends infer T_38 ? { readonly [P_5 in keyof T_38]: Readonly<(JSONCompatible<T> & {})[P][P_1][P_2][P_3][P_4][P_5] extends infer T_39 ? { readonly [P_6 in keyof T_39]: Readonly<(JSONCompatible<T> & {})[P][P_1][P_2][P_3][P_4][P_5][P_6] extends infer T_40 ? { readonly [P_7 in keyof T_40]: Readonly<(JSONCompatible<T> & {})[P][P_1][P_2][P_3][P_4][P_5][P_6][P_7] extends infer T_41 ? { readonly [P_8 in keyof T_41]: Readonly<(JSONCompatible<T> & {})[P][P_1][P_2][P_3][P_4][P_5][P_6][P_7][P_8] extends infer T_42 ? { readonly [P_9 in keyof T_42]: Readonly<(JSONCompatible<T> & {})[P][P_1][P_2][P_3][P_4][P_5][P_6][P_7][P_8][P_9] extends infer T_43 ? { readonly [P_10 in keyof T_43]: Readonly<any>; } : never>; } : never>; } : never>; } : never>; } : never>; } : never>; } : never>; } : never>; } : never>; } : never>; } : never>)) => void;
|
|
10
|
+
state: Readonly<JSONCompatible<T> & {} extends infer T_44 ? { readonly [P in keyof T_44]: Readonly<(JSONCompatible<T> & {})[P] extends infer T_45 ? { readonly [P_1 in keyof T_45]: Readonly<(JSONCompatible<T> & {})[P][P_1] extends infer T_46 ? { readonly [P_2 in keyof T_46]: Readonly<(JSONCompatible<T> & {})[P][P_1][P_2] extends infer T_47 ? { readonly [P_3 in keyof T_47]: Readonly<(JSONCompatible<T> & {})[P][P_1][P_2][P_3] extends infer T_48 ? { readonly [P_4 in keyof T_48]: Readonly<(JSONCompatible<T> & {})[P][P_1][P_2][P_3][P_4] extends infer T_49 ? { readonly [P_5 in keyof T_49]: Readonly<(JSONCompatible<T> & {})[P][P_1][P_2][P_3][P_4][P_5] extends infer T_50 ? { readonly [P_6 in keyof T_50]: Readonly<(JSONCompatible<T> & {})[P][P_1][P_2][P_3][P_4][P_5][P_6] extends infer T_51 ? { readonly [P_7 in keyof T_51]: Readonly<(JSONCompatible<T> & {})[P][P_1][P_2][P_3][P_4][P_5][P_6][P_7] extends infer T_52 ? { readonly [P_8 in keyof T_52]: Readonly<(JSONCompatible<T> & {})[P][P_1][P_2][P_3][P_4][P_5][P_6][P_7][P_8] extends infer T_53 ? { readonly [P_9 in keyof T_53]: Readonly<(JSONCompatible<T> & {})[P][P_1][P_2][P_3][P_4][P_5][P_6][P_7][P_8][P_9] extends infer T_54 ? { readonly [P_10 in keyof T_54]: Readonly<any>; } : never>; } : never>; } : never>; } : never>; } : never>; } : never>; } : never>; } : never>; } : never>; } : never>; } : never>;
|
|
11
11
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "state-in-url",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2",
|
|
4
4
|
"description": "Library to store state in browser URL, includes hook for NextJS, hook for pure React, and low level helpers.",
|
|
5
5
|
"homepage": "https://github.com/asmyshlyaev177/state-in-url#readme",
|
|
6
6
|
"keywords": [
|
|
@@ -45,8 +45,8 @@
|
|
|
45
45
|
"type": "module",
|
|
46
46
|
"exports": {
|
|
47
47
|
"import": {
|
|
48
|
-
"
|
|
49
|
-
"
|
|
48
|
+
"types": "./dist/index.d.ts",
|
|
49
|
+
"default": "./dist/index.js"
|
|
50
50
|
},
|
|
51
51
|
"module": {
|
|
52
52
|
"types": "./dist/index.js",
|
|
@@ -66,18 +66,31 @@
|
|
|
66
66
|
}
|
|
67
67
|
},
|
|
68
68
|
"scripts": {
|
|
69
|
-
"test:unit": "
|
|
69
|
+
"test:unit": "wireit",
|
|
70
70
|
"test:int": "playwright test",
|
|
71
|
+
"test": "wireit",
|
|
71
72
|
"dev": "wireit",
|
|
72
73
|
"dev:lib": "wireit",
|
|
73
74
|
"dev:nextjs": "wireit",
|
|
74
75
|
"bump": "standard-version",
|
|
75
76
|
"build": "wireit",
|
|
77
|
+
"build:demo": "cd packages/example-nextjs && npx cross-env DEMO=true npm run build",
|
|
76
78
|
"cleanup": "rm -rf dist",
|
|
77
79
|
"setup": "playwright install --with-deps",
|
|
78
|
-
"prepare": "husky"
|
|
80
|
+
"prepare": "npx husky"
|
|
79
81
|
},
|
|
80
82
|
"wireit": {
|
|
83
|
+
"test": {
|
|
84
|
+
"dependencies": [
|
|
85
|
+
"build",
|
|
86
|
+
"test:unit",
|
|
87
|
+
"dev:nextjs"
|
|
88
|
+
],
|
|
89
|
+
"command": "npx playwright test --project=chromium"
|
|
90
|
+
},
|
|
91
|
+
"test:unit": {
|
|
92
|
+
"command": "npx jest"
|
|
93
|
+
},
|
|
81
94
|
"dev": {
|
|
82
95
|
"dependencies": [
|
|
83
96
|
"dev:lib"
|
|
@@ -100,7 +113,7 @@
|
|
|
100
113
|
"command": "cd packages/example-nextjs && npm run dev",
|
|
101
114
|
"service": {
|
|
102
115
|
"readyWhen": {
|
|
103
|
-
"lineMatches": "
|
|
116
|
+
"lineMatches": "Ready in"
|
|
104
117
|
}
|
|
105
118
|
}
|
|
106
119
|
},
|