Skip to content

Commit

Permalink
chore(release): 4.1.9 [skip ci]
Browse files Browse the repository at this point in the history
## [4.1.9](v4.1.8...v4.1.9) (2025-01-30)

### Bug Fixes

* reset state independent from URL in 'reset' cb ([9392a19](9392a19))
  • Loading branch information
semantic-release-bot committed Jan 30, 2025
1 parent 9392a19 commit 5021922
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
## [4.1.9](https://github.com/asmyshlyaev177/state-in-url/compare/v4.1.8...v4.1.9) (2025-01-30)


### Bug Fixes

* reset state independent from URL in 'reset' cb ([9392a19](https://github.com/asmyshlyaev177/state-in-url/commit/9392a19b3863bc73469ceaf32ae5aa686b5845c5))

## [4.1.8](https://github.com/asmyshlyaev177/state-in-url/compare/v4.1.7...v4.1.8) (2024-12-10)


Expand Down
2 changes: 1 addition & 1 deletion dist/useUrlStateBase/useUrlStateBase.mjs
Original file line number Diff line number Diff line change
@@ -1 +1 @@
import i from"react";import{TIMEOUT as R}from"../constants/constants.mjs";import{useInsertionEffect as T}from"../useInsertionEffect.mjs";import{useSharedState as v}from"../useSharedState/useSharedState.mjs";import{useUrlEncode as L}from"../useUrlEncode/useUrlEncode.mjs";import{filterUnknownParamsClient as P}from"../utils.mjs";function b(t,o,u){const{parse:a,stringify:n}=L(t),{state:l,getState:r,setState:s}=v(t,()=>u?.({parse:a})||t),m=i.useRef(void 0);T(()=>{const e=()=>{const w=a(P(t));s(w)};return window.addEventListener($,e),()=>{window.removeEventListener($,e),clearTimeout(m.current)}},[s]);const c=i.useRef([]),p=i.useCallback((e,w)=>{const d=typeof e=="function"?e(r()):{...r(),...e},h=n(d,y(t)),S=`${window.location.pathname}${h.length?"?":""}${h}${window.location.hash}`,E=`${window.location.pathname}${window.location.search}${window.location.hash}`;if(S===E)return;s(d);const{replace:g,...k}=w||{};c.current.push([g?"replace":"push",S,k]),clearTimeout(m.current),queueMicrotask(()=>{c.current.length&&(m.current=setTimeout(()=>{const f=c.current.at(-1);c.current=[],o[f[0]](f[1],f[2])},R))})},[o,n,r]),U=i.useCallback(e=>{p(t,e)},[p]);return{updateState:s,updateUrl:p,state:l,reset:U,getState:r}}function y(t){const o=Object.keys(t),u=window.location.search,a=new URLSearchParams(u),n=new URLSearchParams;return a.forEach((l,r)=>!o.includes(r)&&n.set(r,l)),n}const $="popstate";export{b as useUrlStateBase};
import i from"react";import{TIMEOUT as R}from"../constants/constants.mjs";import{useInsertionEffect as T}from"../useInsertionEffect.mjs";import{useSharedState as v}from"../useSharedState/useSharedState.mjs";import{useUrlEncode as L}from"../useUrlEncode/useUrlEncode.mjs";import{filterUnknownParamsClient as P}from"../utils.mjs";function b(t,a,u){const{parse:s,stringify:n}=L(t),{state:l,getState:r,setState:o}=v(t,()=>u?.({parse:s})||t),m=i.useRef(void 0);T(()=>{const e=()=>{const w=s(P(t));o(w)};return window.addEventListener(U,e),()=>{window.removeEventListener(U,e),clearTimeout(m.current)}},[o]);const c=i.useRef([]),p=i.useCallback((e,w)=>{const d=typeof e=="function"?e(r()):{...r(),...e};o(d);const h=n(d,y(t)),S=`${window.location.pathname}${h.length?"?":""}${h}${window.location.hash}`,$=`${window.location.pathname}${window.location.search}${window.location.hash}`;if(S===$)return;const{replace:g,...k}=w||{};c.current.push([g?"replace":"push",S,k]),clearTimeout(m.current),queueMicrotask(()=>{c.current.length&&(m.current=setTimeout(()=>{const f=c.current.at(-1);c.current=[],a[f[0]](f[1],f[2])},R))})},[a,n,r]),E=i.useCallback(e=>{p(t,e)},[p,o]);return{updateState:o,updateUrl:p,state:l,reset:E,getState:r}}function y(t){const a=Object.keys(t),u=window.location.search,s=new URLSearchParams(u),n=new URLSearchParams;return s.forEach((l,r)=>!a.includes(r)&&n.set(r,l)),n}const U="popstate";export{b as useUrlStateBase};
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "state-in-url",
"version": "4.1.8",
"version": "4.1.9",
"description": "Store state in URL as in object, types and structure are preserved, with TS validation. Same API as React.useState, wthout any hasssle or boilerplate. Next.js@14-15 and react-router@6-7.",
"homepage": "https://state-in-url.dev",
"repository": {
Expand Down

0 comments on commit 5021922

Please sign in to comment.