New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@ahooksjs/use-url-state

Package Overview
Dependencies
Maintainers
5
Versions
68
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@ahooksjs/use-url-state - npm Package Compare versions

Comparing version 2.5.5 to 2.5.6

2

dist/ahooks-use-url-state.js

@@ -17,2 +17,2 @@ !function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e(require("React")):"function"==typeof define&&define.amd?define(["React"],e):"object"==typeof exports?exports.ahooksUseUrlState=e(require("React")):t.ahooksUseUrlState=e(t.React)}(this,(function(t){return function(t){var e={};function r(n){if(e[n])return e[n].exports;var o=e[n]={i:n,l:!1,exports:{}};return t[n].call(o.exports,o,o.exports,r),o.l=!0,o.exports}return r.m=t,r.c=e,r.d=function(t,e,n){r.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:n})},r.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},r.t=function(t,e){if(1&e&&(t=r(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var o in t)r.d(n,o,function(e){return t[e]}.bind(null,o));return n},r.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return r.d(e,"a",e),e},r.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},r.p="",r(r.s=19)}([function(e,r){e.exports=t},function(t,e,r){"use strict";function n(t,e){t.prototype=Object.create(e.prototype),t.prototype.constructor=t,t.__proto__=e}r.d(e,"a",(function(){return n}))},function(t,e,r){t.exports=r(11)()},function(t,e,r){"use strict";const n=r(8),o=r(9),i=r(10);function a(t){if("string"!=typeof t||1!==t.length)throw new TypeError("arrayFormatSeparator must be single character string")}function c(t,e){return e.encode?e.strict?n(t):encodeURIComponent(t):t}function s(t,e){return e.decode?o(t):t}function u(t){const e=t.indexOf("#");return-1!==e&&(t=t.slice(0,e)),t}function f(t){const e=(t=u(t)).indexOf("?");return-1===e?"":t.slice(e+1)}function p(t,e){return e.parseNumbers&&!Number.isNaN(Number(t))&&"string"==typeof t&&""!==t.trim()?t=Number(t):!e.parseBooleans||null===t||"true"!==t.toLowerCase()&&"false"!==t.toLowerCase()||(t="true"===t.toLowerCase()),t}function l(t,e){a((e=Object.assign({decode:!0,sort:!0,arrayFormat:"none",arrayFormatSeparator:",",parseNumbers:!1,parseBooleans:!1},e)).arrayFormatSeparator);const r=function(t){let e;switch(t.arrayFormat){case"index":return(t,r,n)=>{e=/\[(\d*)\]$/.exec(t),t=t.replace(/\[\d*\]$/,""),e?(void 0===n[t]&&(n[t]={}),n[t][e[1]]=r):n[t]=r};case"bracket":return(t,r,n)=>{e=/(\[\])$/.exec(t),t=t.replace(/\[\]$/,""),e?void 0!==n[t]?n[t]=[].concat(n[t],r):n[t]=[r]:n[t]=r};case"comma":case"separator":return(e,r,n)=>{const o="string"==typeof r&&r.includes(t.arrayFormatSeparator),i="string"==typeof r&&!o&&s(r,t).includes(t.arrayFormatSeparator);r=i?s(r,t):r;const a=o||i?r.split(t.arrayFormatSeparator).map(e=>s(e,t)):null===r?r:s(r,t);n[e]=a};default:return(t,e,r)=>{void 0!==r[t]?r[t]=[].concat(r[t],e):r[t]=e}}}(e),n=Object.create(null);if("string"!=typeof t)return n;if(!(t=t.trim().replace(/^[?#&]/,"")))return n;for(const o of t.split("&")){let[t,a]=i(e.decode?o.replace(/\+/g," "):o,"=");a=void 0===a?null:["comma","separator"].includes(e.arrayFormat)?a:s(a,e),r(s(t,e),a,n)}for(const t of Object.keys(n)){const r=n[t];if("object"==typeof r&&null!==r)for(const t of Object.keys(r))r[t]=p(r[t],e);else n[t]=p(r,e)}return!1===e.sort?n:(!0===e.sort?Object.keys(n).sort():Object.keys(n).sort(e.sort)).reduce((t,e)=>{const r=n[e];return Boolean(r)&&"object"==typeof r&&!Array.isArray(r)?t[e]=function t(e){return Array.isArray(e)?e.sort():"object"==typeof e?t(Object.keys(e)).sort((t,e)=>Number(t)-Number(e)).map(t=>e[t]):e}(r):t[e]=r,t},Object.create(null))}e.extract=f,e.parse=l,e.stringify=(t,e)=>{if(!t)return"";a((e=Object.assign({encode:!0,strict:!0,arrayFormat:"none",arrayFormatSeparator:","},e)).arrayFormatSeparator);const r=r=>e.skipNull&&null==t[r]||e.skipEmptyString&&""===t[r],n=function(t){switch(t.arrayFormat){case"index":return e=>(r,n)=>{const o=r.length;return void 0===n||t.skipNull&&null===n||t.skipEmptyString&&""===n?r:null===n?[...r,[c(e,t),"[",o,"]"].join("")]:[...r,[c(e,t),"[",c(o,t),"]=",c(n,t)].join("")]};case"bracket":return e=>(r,n)=>void 0===n||t.skipNull&&null===n||t.skipEmptyString&&""===n?r:null===n?[...r,[c(e,t),"[]"].join("")]:[...r,[c(e,t),"[]=",c(n,t)].join("")];case"comma":case"separator":return e=>(r,n)=>null==n||0===n.length?r:0===r.length?[[c(e,t),"=",c(n,t)].join("")]:[[r,c(n,t)].join(t.arrayFormatSeparator)];default:return e=>(r,n)=>void 0===n||t.skipNull&&null===n||t.skipEmptyString&&""===n?r:null===n?[...r,c(e,t)]:[...r,[c(e,t),"=",c(n,t)].join("")]}}(e),o={};for(const e of Object.keys(t))r(e)||(o[e]=t[e]);const i=Object.keys(o);return!1!==e.sort&&i.sort(e.sort),i.map(r=>{const o=t[r];return void 0===o?"":null===o?c(r,e):Array.isArray(o)?o.reduce(n(r),[]).join("&"):c(r,e)+"="+c(o,e)}).filter(t=>t.length>0).join("&")},e.parseUrl=(t,e)=>{e=Object.assign({decode:!0},e);const[r,n]=i(t,"#");return Object.assign({url:r.split("?")[0]||"",query:l(f(t),e)},e&&e.parseFragmentIdentifier&&n?{fragmentIdentifier:s(n,e)}:{})},e.stringifyUrl=(t,r)=>{r=Object.assign({encode:!0,strict:!0},r);const n=u(t.url).split("?")[0]||"",o=e.extract(t.url),i=e.parse(o,{sort:!1}),a=Object.assign(i,t.query);let s=e.stringify(a,r);s&&(s="?"+s);let f=function(t){let e="";const r=t.indexOf("#");return-1!==r&&(e=t.slice(r)),e}(t.url);return t.fragmentIdentifier&&(f="#"+c(t.fragmentIdentifier,r)),`${n}${s}${f}`}},function(t,e,r){"use strict";(function(t){var n=r(0),o=r.n(n),i=r(1),a=r(2),c=r.n(a),s="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:void 0!==t?t:{};function u(t){var e=[];return{on:function(t){e.push(t)},off:function(t){e=e.filter((function(e){return e!==t}))},get:function(){return t},set:function(r,n){t=r,e.forEach((function(e){return e(t,n)}))}}}var f=o.a.createContext||function(t,e){var r,o,a,f="__create-react-context-"+((s[a="__global_unique_id__"]=(s[a]||0)+1)+"__"),p=function(t){function r(){var e;return(e=t.apply(this,arguments)||this).emitter=u(e.props.value),e}Object(i.a)(r,t);var n=r.prototype;return n.getChildContext=function(){var t;return(t={})[f]=this.emitter,t},n.componentWillReceiveProps=function(t){if(this.props.value!==t.value){var r,n=this.props.value,o=t.value;((i=n)===(a=o)?0!==i||1/i==1/a:i!=i&&a!=a)?r=0:(r="function"==typeof e?e(n,o):1073741823,0!==(r|=0)&&this.emitter.set(t.value,r))}var i,a},n.render=function(){return this.props.children},r}(n.Component);p.childContextTypes=((r={})[f]=c.a.object.isRequired,r);var l=function(e){function r(){var t;return(t=e.apply(this,arguments)||this).state={value:t.getValue()},t.onUpdate=function(e,r){0!=((0|t.observedBits)&r)&&t.setState({value:t.getValue()})},t}Object(i.a)(r,e);var n=r.prototype;return n.componentWillReceiveProps=function(t){var e=t.observedBits;this.observedBits=null==e?1073741823:e},n.componentDidMount=function(){this.context[f]&&this.context[f].on(this.onUpdate);var t=this.props.observedBits;this.observedBits=null==t?1073741823:t},n.componentWillUnmount=function(){this.context[f]&&this.context[f].off(this.onUpdate)},n.getValue=function(){return this.context[f]?this.context[f].get():t},n.render=function(){return(t=this.props.children,Array.isArray(t)?t[0]:t)(this.state.value);var t},r}(n.Component);return l.contextTypes=((o={})[f]=c.a.object,o),{Provider:p,Consumer:l}};e.a=f}).call(this,r(13))},function(t,e,r){var n=r(14);t.exports=y,t.exports.parse=i,t.exports.compile=function(t,e){return c(i(t,e),e)},t.exports.tokensToFunction=c,t.exports.tokensToRegExp=l;var o=new RegExp(["(\\\\.)","([\\/.])?(?:(?:\\:(\\w+)(?:\\(((?:\\\\.|[^\\\\()])+)\\))?|\\(((?:\\\\.|[^\\\\()])+)\\))([+*?])?|(\\*))"].join("|"),"g");function i(t,e){for(var r,n=[],i=0,a=0,c="",f=e&&e.delimiter||"/";null!=(r=o.exec(t));){var p=r[0],l=r[1],y=r.index;if(c+=t.slice(a,y),a=y+p.length,l)c+=l[1];else{var d=t[a],m=r[2],h=r[3],v=r[4],g=r[5],b=r[6],x=r[7];c&&(n.push(c),c="");var S=null!=m&&null!=d&&d!==m,j="+"===b||"*"===b,O="?"===b||"*"===b,w=r[2]||f,$=v||g;n.push({name:h||i++,prefix:m||"",delimiter:w,optional:O,repeat:j,partial:S,asterisk:!!x,pattern:$?u($):x?".*":"[^"+s(w)+"]+?"})}}return a<t.length&&(c+=t.substr(a)),c&&n.push(c),n}function a(t){return encodeURI(t).replace(/[\/?#]/g,(function(t){return"%"+t.charCodeAt(0).toString(16).toUpperCase()}))}function c(t,e){for(var r=new Array(t.length),o=0;o<t.length;o++)"object"==typeof t[o]&&(r[o]=new RegExp("^(?:"+t[o].pattern+")$",p(e)));return function(e,o){for(var i="",c=e||{},s=(o||{}).pretty?a:encodeURIComponent,u=0;u<t.length;u++){var f=t[u];if("string"!=typeof f){var p,l=c[f.name];if(null==l){if(f.optional){f.partial&&(i+=f.prefix);continue}throw new TypeError('Expected "'+f.name+'" to be defined')}if(n(l)){if(!f.repeat)throw new TypeError('Expected "'+f.name+'" to not repeat, but received `'+JSON.stringify(l)+"`");if(0===l.length){if(f.optional)continue;throw new TypeError('Expected "'+f.name+'" to not be empty')}for(var y=0;y<l.length;y++){if(p=s(l[y]),!r[u].test(p))throw new TypeError('Expected all "'+f.name+'" to match "'+f.pattern+'", but received `'+JSON.stringify(p)+"`");i+=(0===y?f.prefix:f.delimiter)+p}}else{if(p=f.asterisk?encodeURI(l).replace(/[?#]/g,(function(t){return"%"+t.charCodeAt(0).toString(16).toUpperCase()})):s(l),!r[u].test(p))throw new TypeError('Expected "'+f.name+'" to match "'+f.pattern+'", but received "'+p+'"');i+=f.prefix+p}}else i+=f}return i}}function s(t){return t.replace(/([.+*?=^!:${}()[\]|\/\\])/g,"\\$1")}function u(t){return t.replace(/([=!:$\/()])/g,"\\$1")}function f(t,e){return t.keys=e,t}function p(t){return t&&t.sensitive?"":"i"}function l(t,e,r){n(e)||(r=e||r,e=[]);for(var o=(r=r||{}).strict,i=!1!==r.end,a="",c=0;c<t.length;c++){var u=t[c];if("string"==typeof u)a+=s(u);else{var l=s(u.prefix),y="(?:"+u.pattern+")";e.push(u),u.repeat&&(y+="(?:"+l+y+")*"),a+=y=u.optional?u.partial?l+"("+y+")?":"(?:"+l+"("+y+"))?":l+"("+y+")"}}var d=s(r.delimiter||"/"),m=a.slice(-d.length)===d;return o||(a=(m?a.slice(0,-d.length):a)+"(?:"+d+"(?=$))?"),a+=i?"$":o&&m?"":"(?="+d+"|$)",f(new RegExp("^"+a,p(r)),e)}function y(t,e,r){return n(e)||(r=e||r,e=[]),r=r||{},t instanceof RegExp?function(t,e){var r=t.source.match(/\((?!\?)/g);if(r)for(var n=0;n<r.length;n++)e.push({name:n,prefix:null,delimiter:null,optional:!1,repeat:!1,partial:!1,asterisk:!1,pattern:null});return f(t,e)}(t,e):n(t)?function(t,e,r){for(var n=[],o=0;o<t.length;o++)n.push(y(t[o],e,r).source);return f(new RegExp("(?:"+n.join("|")+")",p(r)),e)}(t,e,r):function(t,e,r){return l(i(t,r),e,r)}(t,e,r)}},,function(t,e,r){"use strict";var n=r(17),o={childContextTypes:!0,contextType:!0,contextTypes:!0,defaultProps:!0,displayName:!0,getDefaultProps:!0,getDerivedStateFromError:!0,getDerivedStateFromProps:!0,mixins:!0,propTypes:!0,type:!0},i={name:!0,length:!0,prototype:!0,caller:!0,callee:!0,arguments:!0,arity:!0},a={$$typeof:!0,compare:!0,defaultProps:!0,displayName:!0,propTypes:!0,type:!0},c={};function s(t){return n.isMemo(t)?a:c[t.$$typeof]||o}c[n.ForwardRef]={$$typeof:!0,render:!0,defaultProps:!0,displayName:!0,propTypes:!0},c[n.Memo]=a;var u=Object.defineProperty,f=Object.getOwnPropertyNames,p=Object.getOwnPropertySymbols,l=Object.getOwnPropertyDescriptor,y=Object.getPrototypeOf,d=Object.prototype;t.exports=function t(e,r,n){if("string"!=typeof r){if(d){var o=y(r);o&&o!==d&&t(e,o,n)}var a=f(r);p&&(a=a.concat(p(r)));for(var c=s(e),m=s(r),h=0;h<a.length;++h){var v=a[h];if(!(i[v]||n&&n[v]||m&&m[v]||c&&c[v])){var g=l(r,v);try{u(e,v,g)}catch(t){}}}}return e}},function(t,e,r){"use strict";t.exports=t=>encodeURIComponent(t).replace(/[!'()*]/g,t=>"%"+t.charCodeAt(0).toString(16).toUpperCase())},function(t,e,r){"use strict";var n=new RegExp("%[a-f0-9]{2}","gi"),o=new RegExp("(%[a-f0-9]{2})+","gi");function i(t,e){try{return decodeURIComponent(t.join(""))}catch(t){}if(1===t.length)return t;e=e||1;var r=t.slice(0,e),n=t.slice(e);return Array.prototype.concat.call([],i(r),i(n))}function a(t){try{return decodeURIComponent(t)}catch(o){for(var e=t.match(n),r=1;r<e.length;r++)e=(t=i(e,r).join("")).match(n);return t}}t.exports=function(t){if("string"!=typeof t)throw new TypeError("Expected `encodedURI` to be of type `string`, got `"+typeof t+"`");try{return t=t.replace(/\+/g," "),decodeURIComponent(t)}catch(e){return function(t){for(var e={"%FE%FF":"��","%FF%FE":"��"},r=o.exec(t);r;){try{e[r[0]]=decodeURIComponent(r[0])}catch(t){var n=a(r[0]);n!==r[0]&&(e[r[0]]=n)}r=o.exec(t)}e["%C2"]="�";for(var i=Object.keys(e),c=0;c<i.length;c++){var s=i[c];t=t.replace(new RegExp(s,"g"),e[s])}return t}(t)}}},function(t,e,r){"use strict";t.exports=(t,e)=>{if("string"!=typeof t||"string"!=typeof e)throw new TypeError("Expected the arguments to be of type `string`");if(""===e)return[t];const r=t.indexOf(e);return-1===r?[t]:[t.slice(0,r),t.slice(r+e.length)]}},function(t,e,r){"use strict";var n=r(12);function o(){}function i(){}i.resetWarningCache=o,t.exports=function(){function t(t,e,r,o,i,a){if(a!==n){var c=new Error("Calling PropTypes validators directly is not supported by the `prop-types` package. Use PropTypes.checkPropTypes() to call them. Read more at http://fb.me/use-check-prop-types");throw c.name="Invariant Violation",c}}function e(){return t}t.isRequired=t;var r={array:t,bool:t,func:t,number:t,object:t,string:t,symbol:t,any:t,arrayOf:e,element:t,elementType:t,instanceOf:e,node:t,objectOf:e,oneOf:e,oneOfType:e,shape:e,exact:e,checkPropTypes:i,resetWarningCache:o};return r.PropTypes=r,r}},function(t,e,r){"use strict";t.exports="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED"},function(t,e){var r;r=function(){return this}();try{r=r||new Function("return this")()}catch(t){"object"==typeof window&&(r=window)}t.exports=r},function(t,e){t.exports=Array.isArray||function(t){return"[object Array]"==Object.prototype.toString.call(t)}},function(t,e,r){"use strict";t.exports=r(16)},function(t,e,r){"use strict";

* LICENSE file in the root directory of this source tree.
*/var n="function"==typeof Symbol&&Symbol.for,o=n?Symbol.for("react.element"):60103,i=n?Symbol.for("react.portal"):60106,a=n?Symbol.for("react.fragment"):60107,c=n?Symbol.for("react.strict_mode"):60108,s=n?Symbol.for("react.profiler"):60114,u=n?Symbol.for("react.provider"):60109,f=n?Symbol.for("react.context"):60110,p=n?Symbol.for("react.async_mode"):60111,l=n?Symbol.for("react.concurrent_mode"):60111,y=n?Symbol.for("react.forward_ref"):60112,d=n?Symbol.for("react.suspense"):60113,m=n?Symbol.for("react.suspense_list"):60120,h=n?Symbol.for("react.memo"):60115,v=n?Symbol.for("react.lazy"):60116,g=n?Symbol.for("react.block"):60121,b=n?Symbol.for("react.fundamental"):60117,x=n?Symbol.for("react.responder"):60118,S=n?Symbol.for("react.scope"):60119;function j(t){if("object"==typeof t&&null!==t){var e=t.$$typeof;switch(e){case o:switch(t=t.type){case p:case l:case a:case s:case c:case d:return t;default:switch(t=t&&t.$$typeof){case f:case y:case v:case h:case u:return t;default:return e}}case i:return e}}}function O(t){return j(t)===l}e.AsyncMode=p,e.ConcurrentMode=l,e.ContextConsumer=f,e.ContextProvider=u,e.Element=o,e.ForwardRef=y,e.Fragment=a,e.Lazy=v,e.Memo=h,e.Portal=i,e.Profiler=s,e.StrictMode=c,e.Suspense=d,e.isAsyncMode=function(t){return O(t)||j(t)===p},e.isConcurrentMode=O,e.isContextConsumer=function(t){return j(t)===f},e.isContextProvider=function(t){return j(t)===u},e.isElement=function(t){return"object"==typeof t&&null!==t&&t.$$typeof===o},e.isForwardRef=function(t){return j(t)===y},e.isFragment=function(t){return j(t)===a},e.isLazy=function(t){return j(t)===v},e.isMemo=function(t){return j(t)===h},e.isPortal=function(t){return j(t)===i},e.isProfiler=function(t){return j(t)===s},e.isStrictMode=function(t){return j(t)===c},e.isSuspense=function(t){return j(t)===d},e.isValidElementType=function(t){return"string"==typeof t||"function"==typeof t||t===a||t===l||t===s||t===c||t===d||t===m||"object"==typeof t&&null!==t&&(t.$$typeof===v||t.$$typeof===h||t.$$typeof===u||t.$$typeof===f||t.$$typeof===y||t.$$typeof===b||t.$$typeof===x||t.$$typeof===S||t.$$typeof===g)},e.typeOf=j},function(t,e,r){"use strict";r.r(e);var n=r(3),o=r(0),i=r.n(o),a=r(1);r(2);function c(){return(Object.assign||function(t){for(var e=1;e<arguments.length;e++){var r=arguments[e];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(t[n]=r[n])}return t}).apply(this,arguments)}function s(t){return"/"===t.charAt(0)}function u(t,e){for(var r=e,n=r+1,o=t.length;n<o;r+=1,n+=1)t[r]=t[n];t.pop()}var f=function(t,e){void 0===e&&(e="");var r,n=t&&t.split("/")||[],o=e&&e.split("/")||[],i=t&&s(t),a=e&&s(e),c=i||a;if(t&&s(t)?o=n:n.length&&(o.pop(),o=o.concat(n)),!o.length)return"/";if(o.length){var f=o[o.length-1];r="."===f||".."===f||""===f}else r=!1;for(var p=0,l=o.length;l>=0;l--){var y=o[l];"."===y?u(o,l):".."===y?(u(o,l),p++):p&&(u(o,l),p--)}if(!c)for(;p--;p)o.unshift("..");!c||""===o[0]||o[0]&&s(o[0])||o.unshift("");var d=o.join("/");return r&&"/"!==d.substr(-1)&&(d+="/"),d};var p=function(t,e){if(!t)throw new Error("Invariant failed")};function l(t){var e=t.pathname,r=t.search,n=t.hash,o=e||"/";return r&&"?"!==r&&("?"===r.charAt(0)?r:"?"+r),n&&"#"!==n&&("#"===n.charAt(0)?n:"#"+n),o}function y(t,e,r,n){var o;"string"==typeof t?(function(t){var e=t||"/",r="",n="",o=e.indexOf("#");-1!==o&&(e.substr(o),e.substr(0,o));var i=e.indexOf("?");return-1!==i&&(e.substr(i),e.substr(0,i)),{pathname:e,search:"?"===r?"":r,hash:"#"===n?"":n}}(t)).state=e:(void 0===c({},t).pathname&&(o.pathname=""),o.search?"?"!==o.search.charAt(0)&&(o.search="?"+o.search):o.search="",o.hash?"#"!==o.hash.charAt(0)&&(o.hash="#"+o.hash):o.hash="",void 0!==e&&void 0===o.state&&(o.state=e));try{o.pathname=decodeURI(o.pathname)}catch(t){throw t instanceof URIError?new URIError('Pathname "'+o.pathname+'" could not be decoded. This is likely caused by an invalid percent-encoding.'):t}return r&&(o.key=r),n?o.pathname?"/"!==o.pathname.charAt(0)&&(o.pathname=f(o.pathname,n.pathname)):o.pathname=n.pathname:o.pathname||(o.pathname="/"),o}function d(){var t=null;var e=[];return{setPrompt:function(e){return e,function(){t===e&&null}},confirmTransitionTo:function(e,r,n,o){if(null!=t){var i="function"==typeof t?t(e,r):t;"string"==typeof i?"function"==typeof n?n(i,o):o(!0):o(!1!==i)}else o(!0)},appendListener:function(t){var r=!0;function n(){r&&t.apply(void 0,arguments)}return e.push(n),function(){!1,e.filter((function(t){return t!==n}))}},notifyListeners:function(){for(var t=arguments.length,r=new Array(t),n=0;n<t;n++)r[n]=arguments[n];e.forEach((function(t){return t.apply(void 0,r)}))}}}"undefined"==typeof window||!window.document||window.document.createElement;function m(t,e,r){return Math.min(Math.max(t,e),r)}function h(t){void 0===t&&{};var e=t,r=e.getUserConfirmation,n=e.initialEntries,o=void 0===n?["/"]:n,i=e.initialIndex,a=void 0===i?0:i,s=e.keyLength,u=void 0===s?6:s,f=d();function p(t){c(S,t),S.length=S.entries.length,f.notifyListeners(S.location,S.action)}function h(){return Math.random().toString(36).substr(2,u)}var v=m(a,0,o.length-1),g=o.map((function(t){return y(t,void 0,"string"==typeof t?h():t.key||h())})),b=l;function x(t){var e=m(S.index+t,0,S.entries.length-1),n=S.entries[e];f.confirmTransitionTo(n,"POP",r,(function(t){t?p({action:"POP",location:n,index:e}):p()}))}var S={length:g.length,action:"POP",location:g[v],index:v,entries:g,createHref:b,push:function(t,e){var n=y(t,e,h(),S.location);f.confirmTransitionTo(n,"PUSH",r,(function(t){if(t){var e=S.index+1,r=S.entries.slice(0);r.length>e?r.splice(e,r.length-e,n):r.push(n),p({action:"PUSH",location:n,index:e,entries:r})}}))},replace:function(t,e){var n=y(t,e,h(),S.location);f.confirmTransitionTo(n,"REPLACE",r,(function(t){t&&(S.entries[S.index]=n,p({action:"REPLACE",location:n}))}))},go:x,goBack:function(){x(-1)},goForward:function(){x(1)},canGo:function(t){var e=S.index+t;return e>=0&&e<S.entries.length},block:function(t){return void 0===t&&!1,f.setPrompt(t)},listen:function(t){return f.appendListener(t)}};return S}var v=r(4),g=r(5),b=r.n(g);r(15);function x(t,e){if(null==t)return{};var r,n,o={},i=Object.keys(t);for(0;n<i.length;n++)i[n],e.indexOf(r)>=0||(o[r]=t[r]);return o}r(7);var S=function(t){var e=Object(v.a)();return e.displayName=t,e}("Router-History"),j=function(t){var e=Object(v.a)();return e.displayName=t,e}("Router"),O=function(t){function e(e){var r;return(r=t.call(this,e)||this).state={location:e.history.location},r._isMounted=!1,r._pendingLocation=null,e.staticContext||(r.unlisten=e.history.listen((function(t){r._isMounted?r.setState({location:t}):r._pendingLocation=t}))),r}Object(a.a)(e,t),e.computeRootMatch=function(t){return{path:"/",url:"/",params:{},isExact:"/"===t}};var r=e.prototype;return r.componentDidMount=function(){this._isMounted=!0,this._pendingLocation&&this.setState({location:this._pendingLocation})},r.componentWillUnmount=function(){this.unlisten&&this.unlisten()},r.render=function(){return i.a.createElement(j.Provider,{value:{history:this.props.history,location:this.state.location,match:e.computeRootMatch(this.state.location.pathname),staticContext:this.props.staticContext}},i.a.createElement(S.Provider,{children:this.props.children||null,value:this.props.history}))},e}(i.a.Component);i.a.Component;i.a.Component;var w={},$=0;function C(t,e){void 0===e&&{},("string"==typeof e||Array.isArray(e))&&{path:e};var r=e,n=r.path,o=r.exact,i=void 0!==o&&o,a=r.strict,c=void 0!==a&&a,s=r.sensitive,u=void 0!==s&&s;return[].concat(n).reduce((function(e,r){if(!r&&""!==r)return null;if(e)return e;var n=function(t,e){var r=""+e.end+e.strict+e.sensitive,n=w[r]||(w[r]={});if(n[t])return n[t];var o=[],i={regexp:b()(t,o,e),keys:o};return $<1e4&&(n[t]=i),i}(r,{end:i,strict:c,sensitive:u}),o=n.regexp,a=n.keys,s=o.exec(t);if(!s)return null;var f=s[0],p=s.slice(1),l=t===f;return i&&!l?null:{path:r,url:"/"===r&&""===f?"/":f,isExact:l,params:a.reduce((function(t,e,r){return t[e.name]=p[r],t}),{})}}),null)}i.a.Component;function E(t){return"/"===t.charAt(0)?t:"/"+t}function P(t,e){if(!t)return e;var r=E(t);return 0!==e.pathname.indexOf(r)?e:c({},e,{pathname:e.pathname.substr(r.length)})}function R(t){return"string"==typeof t?t:l(t)}function _(t){return function(){p(!1)}}function k(){}i.a.Component;i.a.Component;var T=i.a.useContext;function F(){return T(j).location}var M=function(){return(M=Object.assign||function(t){for(var e,r=1,n=arguments.length;r<n;r++)for(var o in e=arguments[r])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t}).apply(this,arguments)},A=function(t,e){var r="function"==typeof Symbol&&t[Symbol.iterator];if(!r)return t;var n,o,i=r.call(t),a=[];try{for(;(void 0===e||e-- >0)&&!(n=i.next()).done;)a.push(n.value)}catch(t){o={error:t}}finally{try{n&&!n.done&&(r=i.return)&&r.call(i)}finally{if(o)throw o.error}}return a},U={skipNull:!0,skipEmptyString:!0,parseNumbers:!1,parseBooleans:!1};e.default=function(t,e){var r=(e||{}).navigateMode,i=void 0===r?"push":r,a=F(),c=T(S),s=A(Object(o.useState)(!1),2)[1],u=Object(o.useRef)("function"==typeof t?t():t||{}),f=Object(o.useMemo)((function(){return Object(n.parse)(a.search,U)}),[a.search]),p=M(M({},u.current),f);return[p,function(t){var e="function"==typeof t?t(p):t;s((function(t){return!t})),c[i]({hash:a.hash,search:Object(n.stringify)(M(M({},f),e),U)||"?"})}]}}])}));
*/var n="function"==typeof Symbol&&Symbol.for,o=n?Symbol.for("react.element"):60103,i=n?Symbol.for("react.portal"):60106,a=n?Symbol.for("react.fragment"):60107,c=n?Symbol.for("react.strict_mode"):60108,s=n?Symbol.for("react.profiler"):60114,u=n?Symbol.for("react.provider"):60109,f=n?Symbol.for("react.context"):60110,p=n?Symbol.for("react.async_mode"):60111,l=n?Symbol.for("react.concurrent_mode"):60111,y=n?Symbol.for("react.forward_ref"):60112,d=n?Symbol.for("react.suspense"):60113,m=n?Symbol.for("react.suspense_list"):60120,h=n?Symbol.for("react.memo"):60115,v=n?Symbol.for("react.lazy"):60116,g=n?Symbol.for("react.block"):60121,b=n?Symbol.for("react.fundamental"):60117,x=n?Symbol.for("react.responder"):60118,S=n?Symbol.for("react.scope"):60119;function j(t){if("object"==typeof t&&null!==t){var e=t.$$typeof;switch(e){case o:switch(t=t.type){case p:case l:case a:case s:case c:case d:return t;default:switch(t=t&&t.$$typeof){case f:case y:case v:case h:case u:return t;default:return e}}case i:return e}}}function O(t){return j(t)===l}e.AsyncMode=p,e.ConcurrentMode=l,e.ContextConsumer=f,e.ContextProvider=u,e.Element=o,e.ForwardRef=y,e.Fragment=a,e.Lazy=v,e.Memo=h,e.Portal=i,e.Profiler=s,e.StrictMode=c,e.Suspense=d,e.isAsyncMode=function(t){return O(t)||j(t)===p},e.isConcurrentMode=O,e.isContextConsumer=function(t){return j(t)===f},e.isContextProvider=function(t){return j(t)===u},e.isElement=function(t){return"object"==typeof t&&null!==t&&t.$$typeof===o},e.isForwardRef=function(t){return j(t)===y},e.isFragment=function(t){return j(t)===a},e.isLazy=function(t){return j(t)===v},e.isMemo=function(t){return j(t)===h},e.isPortal=function(t){return j(t)===i},e.isProfiler=function(t){return j(t)===s},e.isStrictMode=function(t){return j(t)===c},e.isSuspense=function(t){return j(t)===d},e.isValidElementType=function(t){return"string"==typeof t||"function"==typeof t||t===a||t===l||t===s||t===c||t===d||t===m||"object"==typeof t&&null!==t&&(t.$$typeof===v||t.$$typeof===h||t.$$typeof===u||t.$$typeof===f||t.$$typeof===y||t.$$typeof===b||t.$$typeof===x||t.$$typeof===S||t.$$typeof===g)},e.typeOf=j},function(t,e,r){"use strict";r.r(e);var n=r(3),o=r(0),i=r.n(o),a=r(1);r(2);function c(){return(Object.assign||function(t){for(var e=1;e<arguments.length;e++){var r=arguments[e];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(t[n]=r[n])}return t}).apply(this,arguments)}function s(t){return"/"===t.charAt(0)}function u(t,e){for(var r=e,n=r+1,o=t.length;n<o;r+=1,n+=1)t[r]=t[n];t.pop()}var f=function(t,e){void 0===e&&(e="");var r,n=t&&t.split("/")||[],o=e&&e.split("/")||[],i=t&&s(t),a=e&&s(e),c=i||a;if(t&&s(t)?o=n:n.length&&(o.pop(),o=o.concat(n)),!o.length)return"/";if(o.length){var f=o[o.length-1];r="."===f||".."===f||""===f}else r=!1;for(var p=0,l=o.length;l>=0;l--){var y=o[l];"."===y?u(o,l):".."===y?(u(o,l),p++):p&&(u(o,l),p--)}if(!c)for(;p--;p)o.unshift("..");!c||""===o[0]||o[0]&&s(o[0])||o.unshift("");var d=o.join("/");return r&&"/"!==d.substr(-1)&&(d+="/"),d};var p=function(t,e){if(!t)throw new Error("Invariant failed")};function l(t){var e=t.pathname,r=t.search,n=t.hash,o=e||"/";return r&&"?"!==r&&("?"===r.charAt(0)?r:"?"+r),n&&"#"!==n&&("#"===n.charAt(0)?n:"#"+n),o}function y(t,e,r,n){var o;"string"==typeof t?(function(t){var e=t||"/",r="",n="",o=e.indexOf("#");-1!==o&&(e.substr(o),e.substr(0,o));var i=e.indexOf("?");return-1!==i&&(e.substr(i),e.substr(0,i)),{pathname:e,search:"?"===r?"":r,hash:"#"===n?"":n}}(t)).state=e:(void 0===c({},t).pathname&&(o.pathname=""),o.search?"?"!==o.search.charAt(0)&&(o.search="?"+o.search):o.search="",o.hash?"#"!==o.hash.charAt(0)&&(o.hash="#"+o.hash):o.hash="",void 0!==e&&void 0===o.state&&(o.state=e));try{o.pathname=decodeURI(o.pathname)}catch(t){throw t instanceof URIError?new URIError('Pathname "'+o.pathname+'" could not be decoded. This is likely caused by an invalid percent-encoding.'):t}return r&&(o.key=r),n?o.pathname?"/"!==o.pathname.charAt(0)&&(o.pathname=f(o.pathname,n.pathname)):o.pathname=n.pathname:o.pathname||(o.pathname="/"),o}function d(){var t=null;var e=[];return{setPrompt:function(e){return e,function(){t===e&&null}},confirmTransitionTo:function(e,r,n,o){if(null!=t){var i="function"==typeof t?t(e,r):t;"string"==typeof i?"function"==typeof n?n(i,o):o(!0):o(!1!==i)}else o(!0)},appendListener:function(t){var r=!0;function n(){r&&t.apply(void 0,arguments)}return e.push(n),function(){!1,e.filter((function(t){return t!==n}))}},notifyListeners:function(){for(var t=arguments.length,r=new Array(t),n=0;n<t;n++)r[n]=arguments[n];e.forEach((function(t){return t.apply(void 0,r)}))}}}"undefined"==typeof window||!window.document||window.document.createElement;function m(t,e,r){return Math.min(Math.max(t,e),r)}function h(t){void 0===t&&{};var e=t,r=e.getUserConfirmation,n=e.initialEntries,o=void 0===n?["/"]:n,i=e.initialIndex,a=void 0===i?0:i,s=e.keyLength,u=void 0===s?6:s,f=d();function p(t){c(S,t),S.length=S.entries.length,f.notifyListeners(S.location,S.action)}function h(){return Math.random().toString(36).substr(2,u)}var v=m(a,0,o.length-1),g=o.map((function(t){return y(t,void 0,"string"==typeof t?h():t.key||h())})),b=l;function x(t){var e=m(S.index+t,0,S.entries.length-1),n=S.entries[e];f.confirmTransitionTo(n,"POP",r,(function(t){t?p({action:"POP",location:n,index:e}):p()}))}var S={length:g.length,action:"POP",location:g[v],index:v,entries:g,createHref:b,push:function(t,e){var n=y(t,e,h(),S.location);f.confirmTransitionTo(n,"PUSH",r,(function(t){if(t){var e=S.index+1,r=S.entries.slice(0);r.length>e?r.splice(e,r.length-e,n):r.push(n),p({action:"PUSH",location:n,index:e,entries:r})}}))},replace:function(t,e){var n=y(t,e,h(),S.location);f.confirmTransitionTo(n,"REPLACE",r,(function(t){t&&(S.entries[S.index]=n,p({action:"REPLACE",location:n}))}))},go:x,goBack:function(){x(-1)},goForward:function(){x(1)},canGo:function(t){var e=S.index+t;return e>=0&&e<S.entries.length},block:function(t){return void 0===t&&!1,f.setPrompt(t)},listen:function(t){return f.appendListener(t)}};return S}var v=r(4),g=r(5),b=r.n(g);r(15);function x(t,e){if(null==t)return{};var r,n,o={},i=Object.keys(t);for(0;n<i.length;n++)i[n],e.indexOf(r)>=0||(o[r]=t[r]);return o}r(7);var S=function(t){var e=Object(v.a)();return e.displayName=t,e}("Router-History"),j=function(t){var e=Object(v.a)();return e.displayName=t,e}("Router"),O=function(t){function e(e){var r;return(r=t.call(this,e)||this).state={location:e.history.location},r._isMounted=!1,r._pendingLocation=null,e.staticContext||(r.unlisten=e.history.listen((function(t){r._isMounted?r.setState({location:t}):r._pendingLocation=t}))),r}Object(a.a)(e,t),e.computeRootMatch=function(t){return{path:"/",url:"/",params:{},isExact:"/"===t}};var r=e.prototype;return r.componentDidMount=function(){this._isMounted=!0,this._pendingLocation&&this.setState({location:this._pendingLocation})},r.componentWillUnmount=function(){this.unlisten&&this.unlisten()},r.render=function(){return i.a.createElement(j.Provider,{value:{history:this.props.history,location:this.state.location,match:e.computeRootMatch(this.state.location.pathname),staticContext:this.props.staticContext}},i.a.createElement(S.Provider,{children:this.props.children||null,value:this.props.history}))},e}(i.a.Component);i.a.Component;i.a.Component;var w={},$=0;function C(t,e){void 0===e&&{},("string"==typeof e||Array.isArray(e))&&{path:e};var r=e,n=r.path,o=r.exact,i=void 0!==o&&o,a=r.strict,c=void 0!==a&&a,s=r.sensitive,u=void 0!==s&&s;return[].concat(n).reduce((function(e,r){if(!r&&""!==r)return null;if(e)return e;var n=function(t,e){var r=""+e.end+e.strict+e.sensitive,n=w[r]||(w[r]={});if(n[t])return n[t];var o=[],i={regexp:b()(t,o,e),keys:o};return $<1e4&&(n[t]=i),i}(r,{end:i,strict:c,sensitive:u}),o=n.regexp,a=n.keys,s=o.exec(t);if(!s)return null;var f=s[0],p=s.slice(1),l=t===f;return i&&!l?null:{path:r,url:"/"===r&&""===f?"/":f,isExact:l,params:a.reduce((function(t,e,r){return t[e.name]=p[r],t}),{})}}),null)}i.a.Component;function E(t){return"/"===t.charAt(0)?t:"/"+t}function P(t,e){if(!t)return e;var r=E(t);return 0!==e.pathname.indexOf(r)?e:c({},e,{pathname:e.pathname.substr(r.length)})}function R(t){return"string"==typeof t?t:l(t)}function _(t){return function(){p(!1)}}function k(){}i.a.Component;i.a.Component;var T=i.a.useContext;function F(){return T(j).location}var M=function(){return(M=Object.assign||function(t){for(var e,r=1,n=arguments.length;r<n;r++)for(var o in e=arguments[r])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t}).apply(this,arguments)},A=function(t,e){var r="function"==typeof Symbol&&t[Symbol.iterator];if(!r)return t;var n,o,i=r.call(t),a=[];try{for(;(void 0===e||e-- >0)&&!(n=i.next()).done;)a.push(n.value)}catch(t){o={error:t}}finally{try{n&&!n.done&&(r=i.return)&&r.call(i)}finally{if(o)throw o.error}}return a},U={skipNull:!0,skipEmptyString:!0,parseNumbers:!1,parseBooleans:!1};e.default=function(t,e){var r=(e||{}).navigateMode,i=void 0===r?"push":r,a=F(),c=T(S),s=A(Object(o.useState)(!1),2)[1],u=Object(o.useRef)("function"==typeof t?t():t||{}),f=Object(o.useMemo)((function(){return Object(n.parse)(a.search,U)}),[a.search]),p=Object(o.useMemo)((function(){return M(M({},u.current),f)}),[f]);return[p,function(t){var e="function"==typeof t?t(p):t;s((function(t){return!t})),c[i]({hash:a.hash,search:Object(n.stringify)(M(M({},f),e),U)||"?"})}]}}])}));

@@ -66,5 +66,6 @@ var __assign = this && this.__assign || function () {

}, [location.search]);
var targetQuery = useMemo(function () {
return __assign(__assign({}, initialStateRef.current), queryFromUrl);
}, [queryFromUrl]);
var targetQuery = __assign(__assign({}, initialStateRef.current), queryFromUrl);
var setState = function setState(s) {

@@ -71,0 +72,0 @@ var newQuery = typeof s === 'function' ? s(targetQuery) : s; // 1. 如果 setState 后,search 没变化,就需要 update 来触发一次更新。比如 demo1 直接点击 clear,就需要 update 来触发更新。

@@ -76,5 +76,6 @@ "use strict";

}, [location.search]);
var targetQuery = react_1.useMemo(function () {
return __assign(__assign({}, initialStateRef.current), queryFromUrl);
}, [queryFromUrl]);
var targetQuery = __assign(__assign({}, initialStateRef.current), queryFromUrl);
var setState = function setState(s) {

@@ -81,0 +82,0 @@ var newQuery = typeof s === 'function' ? s(targetQuery) : s; // 1. 如果 setState 后,search 没变化,就需要 update 来触发一次更新。比如 demo1 直接点击 clear,就需要 update 来触发更新。

{
"name": "@ahooksjs/use-url-state",
"version": "2.5.5",
"version": "2.5.6",
"description": "A hook that stores the state into url query parameters.",

@@ -5,0 +5,0 @@ "main": "./lib/index.js",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc