state-in-url 3.0.5 → 3.0.7

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/README.CN.md CHANGED
@@ -22,7 +22,7 @@
22
22
 
23
23
  ![演示-gif](https://github.com/asmyshlyaev177/state-in-url/assets/19854148/c9802601-4d42-4362-b3e4-37ff87c3b97f)
24
24
 
25
- <a href="https://state-in-url-asmyshlyaev177.vercel.app/" target="_blank">演示</a> |
25
+ <a href="https://state-in-url.dev/" target="_blank">演示</a> |
26
26
  <a href="https://state-in-url.netlify.app/" target="_blank">DEMO2</a> |
27
27
 
28
28
  <hr />
package/README.KO.md CHANGED
@@ -26,7 +26,7 @@
26
26
  ![데모-gif](https://github.com/asmyshlyaev177/state-in-url/assets/19854148/c9802601-4d42-4362-b3e4-37ff87c3b97f)
27
27
 
28
28
 
29
- <a href="https://state-in-url-asmyshlyaev177.vercel.app/" target="_blank">데모</a> |
29
+ <a href="https://state-in-url.dev" target="_blank">데모</a> |
30
30
  <a href="https://state-in-url.netlify.app/" target="_blank">DEMO2</a> |
31
31
 
32
32
 
package/README.md CHANGED
@@ -23,7 +23,6 @@ English | [한국어](./README.KO.md) | [简体中文](./README.CN.md)
23
23
  [![semantic-release: angular](https://img.shields.io/badge/semantic--release-angular-e10079?logo=semantic-release)]([https://github.com/semantic-release/semantic-release](https://github.com/asmyshlyaev177/state-in-url))
24
24
  ![npm bundle size (minified + gzip)](https://img.shields.io/bundlephobia/minzip/state-in-url.svg)
25
25
 
26
- [![StandWithUkraine](https://raw.githubusercontent.com/vshymanskyy/StandWithUkraine/master/badges/StandWithUkraine.svg)](https://stand-with-ukraine.pp.ua/)
27
26
  </div>
28
27
 
29
28
  <div align="center">
@@ -32,13 +31,15 @@ English | [한국어](./README.KO.md) | [简体中文](./README.CN.md)
32
31
 
33
32
  ![Demo-gif](https://github.com/asmyshlyaev177/state-in-url/blob/master/assets/Demo-gif.gif)
34
33
 
35
- <a href="https://state-in-url-asmyshlyaev177.vercel.app/" target="_blank">DEMO</a> |
34
+ <a href="https://state-in-url.dev" target="_blank">DEMO</a> |
36
35
  <a href="https://state-in-url.netlify.app/" target="_blank">DEMO2</a>
37
36
 
38
37
  <hr />
39
38
 
40
39
  Add a ⭐️ and <a href="https://github.com/asmyshlyaev177" target="_blank">follow me</a> to support the project!
41
40
 
41
+ Will appreciate you feedback/opinion on [discussions](https://github.com/asmyshlyaev177/state-in-url/discussions/1)
42
+
42
43
  Share if it useful for you.
43
44
  [FB](https://www.facebook.com/sharer.php?u=https://github.com/asmyshlyaev177/state-in-url)
44
45
  [LinkedIn](https://www.linkedin.com/sharing/share-offsite/?url=https://github.com/asmyshlyaev177/state-in-url)
@@ -118,6 +119,8 @@ Possibly need to set `"module": "ES2022"`, or `"module": "ESNext"`
118
119
 
119
120
  [Docs](packages/urlstate/next/useUrlState#api)
120
121
 
122
+ [React-Router example](#useurlstate-hook-for-react-router)
123
+
121
124
  ### Usage examples
122
125
 
123
126
  #### Basic
@@ -176,6 +179,9 @@ function MyComponent() {
176
179
 
177
180
  #### With complex state shape
178
181
 
182
+ <details>
183
+ <Summary>Example</Summary>
184
+
179
185
  ```typescript
180
186
  export const form: Form = {
181
187
  name: '',
@@ -190,7 +196,6 @@ type Form = {
190
196
  'agree to terms': boolean;
191
197
  tags: { id: string; value: { text: string; time: Date } }[];
192
198
  };
193
-
194
199
  ```
195
200
 
196
201
  ```typescript
@@ -250,10 +255,16 @@ const tags = [
250
255
  ```
251
256
 
252
257
  [Demo page example code](https://github.com/asmyshlyaev177/state-in-url/blob/master/packages/example-nextjs14/src/app/Form.tsx)
258
+ </details>
259
+
253
260
 
254
261
  #### Auto sync state
255
262
 
256
- ```typescript
263
+ <details>
264
+ <Summary>Example</Summary>
265
+
266
+ ```typescript
267
+
257
268
  const timer = React.useRef(0 as unknown as NodeJS.Timeout);
258
269
  React.useEffect(() => {
259
270
  clearTimeout(timer.current);
@@ -274,8 +285,15 @@ Syncing state `onBlur` will be more aligned with real world usage.
274
285
  <input onBlur={() => updateUrl()} .../>
275
286
  ```
276
287
 
288
+ </details>
289
+
290
+
291
+
277
292
  #### With server side rendering
278
293
 
294
+ <details>
295
+ <Summary>Example</Summary>
296
+
279
297
  ```typescript
280
298
  export default async function Home({ searchParams }: { searchParams: object }) {
281
299
  return (
@@ -294,9 +312,13 @@ const Form = ({ searchParams }: { searchParams: object }) => {
294
312
  }
295
313
  ```
296
314
 
315
+ </details>
316
+
297
317
  #### Using hook in `layout` component
298
318
 
299
- That a tricky part, since nextjs with app router doesn't allow to access searchParams from server side. There is workaround with using middleware, but it isn't pretty and can stop working after nextjs update.
319
+ <details>
320
+ <Summary>Example</Summary>
321
+ That a tricky part, since nextjs with app router doesn't allow to access searchParams from server side. There is workaround with using middleware, but it isn't pretty and can stop working after nextjs update.
300
322
 
301
323
  ```typescript
302
324
  // add to appropriate `layout.tsc`
@@ -340,9 +362,13 @@ export default async function Layout({
340
362
 
341
363
 
342
364
  ```
365
+ </details>
343
366
 
344
367
  #### With arbitrary state shape (not recommended)
345
368
 
369
+ <details>
370
+ <Summary>Example</Summary>
371
+
346
372
  ```typescript
347
373
  'use client'
348
374
  import { useUrlState } from 'state-in-url/next';
@@ -353,6 +379,9 @@ function SettingsComponent() {
353
379
  const { state, updateUrl, updateState } = useUrlState<object>(someObj);
354
380
  }
355
381
  ```
382
+ </details>
383
+
384
+
356
385
 
357
386
  ## useUrlState hook for React-Router
358
387
 
@@ -512,6 +541,8 @@ This project is licensed under the [MIT license](LICENSE).
512
541
 
513
542
  ## Inspiration
514
543
 
544
+ [NUQS](https://github.com/47ng/nuqs)
545
+
515
546
  [Using URL to store state in Vue](https://dev.to/jacobandrewsky/using-url-to-store-state-in-vue-275c)
516
547
 
517
548
  [Storing state in the URL](https://antonz.org/storing-state/)
package/package.json CHANGED
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "name": "state-in-url",
3
- "version": "3.0.5",
3
+ "version": "3.0.7",
4
4
  "description": "Easily share complex state objects between unrelated React components, preserve types and structure, with TS validation. Deep links and url state synchronization wthout any hasssle or boilerplate.",
5
- "homepage": "https://state-in-url-asmyshlyaev177.vercel.app",
5
+ "homepage": "https://state-in-url.dev",
6
6
  "keywords": [
7
7
  "front-end",
8
8
  "state-management",
@@ -103,7 +103,7 @@
103
103
  "test:unit": "wireit",
104
104
  "test:int": "wireit",
105
105
  "test:int:ci": "wireit",
106
- "test:exports": "npx babel-node --extensions .js,.mjs,.ts,.mts --config-file ./babel.config.json -- ./packages/urlstate/exportsTest.ts",
106
+ "test:exports": "npm run build && npx babel-node --extensions .js,.mjs,.ts,.mts --config-file ./babel.config.json -- ./packages/urlstate/exportsTest.ts",
107
107
  "test": "wireit",
108
108
  "tsc": "wireit",
109
109
  "dev": "wireit",
@@ -126,8 +126,7 @@
126
126
  "reinstall": "rm -rf dist .wireit node_modules packages/example-nextjs14/node_modules packages/example-nextjs14/.next packages/example-react/node_modules && npm install",
127
127
  "setup": "playwright install --with-deps",
128
128
  "prepack": "npm run build && cp package.json dist/package.json && npm run build:demo",
129
- "prepare": "npx husky",
130
- "preinstall": "npx only-allow npm"
129
+ "prepare": "npx husky"
131
130
  },
132
131
  "wireit": {
133
132
  "test": {
@@ -136,7 +135,7 @@
136
135
  "test:unit",
137
136
  "build:packages"
138
137
  ],
139
- "command": "npm run test:int"
138
+ "command": "npm run test:exports && npm run test:int"
140
139
  },
141
140
  "kill-next": {
142
141
  "command": "ps aux | grep .next | grep -v grep | awk '{print $2}' | xargs kill -9 2>&1; exit 0"
@@ -304,7 +303,7 @@
304
303
  "command": "cd packages/example-react && npm run build"
305
304
  },
306
305
  "build": {
307
- "command": "rollup -c rollup.config.js --bundleConfigAsCjs && npm run test:exports",
306
+ "command": "rollup -c rollup.config.js --bundleConfigAsCjs",
308
307
  "dependencies": [
309
308
  "cleanup"
310
309
  ]
@@ -386,6 +385,7 @@
386
385
  "jest": "^29.7.0",
387
386
  "jest-environment-jsdom": "^29.7.0",
388
387
  "lint-staged": "^15.2.9",
388
+ "only-allow": "^1.2.1",
389
389
  "playwright": "^1.45.3",
390
390
  "prettier": "^3.2.5",
391
391
  "prettier-plugin-tailwindcss": "^0.6.8",
@@ -399,7 +399,7 @@
399
399
  "ts-node": "^10.9.2",
400
400
  "typescript": "^5.3.3",
401
401
  "wait-on": "^8.0.1",
402
- "wireit": "^0.14.9",
403
- "zx": "^8.1.5"
404
- }
402
+ "wireit": "^0.14.9"
403
+ },
404
+ "packageManager": "npm@10.8.2"
405
405
  }