WordPress/wp-includes/js/dist/router.min.js
desrosj afd36de0b5 Build/Test Tools: Update all build tool related dependencies.
This updates the following dependencies to their latest versions:
- `chalk`
- `cssnano`
- `dotenv`
- `grunt-contrib-cssmin`
- `grunt-contrib-qunit`
- `grunt-webpack`
- `jest-image-snapshot`
- `postcss`
- `sass`
- `sinon`
- `webpack`

Additionally, `npm audit fix` has been run to automatically fix as many issues as possible.

See #58863.
Built from https://develop.svn.wordpress.org/trunk@56390


git-svn-id: http://core.svn.wordpress.org/trunk@55902 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-08-11 16:04:29 +00:00

2 lines
4.2 KiB
JavaScript

/*! This file is auto-generated */
(()=>{"use strict";var e={d:(t,n)=>{for(var r in n)e.o(n,r)&&!e.o(t,r)&&Object.defineProperty(t,r,{enumerable:!0,get:n[r]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r:e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},t={};e.r(t),e.d(t,{privateApis:()=>A});const n=window.wp.element;function r(){return r=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},r.apply(this,arguments)}var o;!function(e){e.Pop="POP",e.Push="PUSH",e.Replace="REPLACE"}(o||(o={}));var a=function(e){return e};var u="beforeunload",i="popstate";function c(e){e.preventDefault(),e.returnValue=""}function s(){var e=[];return{get length(){return e.length},push:function(t){return e.push(t),function(){e=e.filter((function(e){return e!==t}))}},call:function(t){e.forEach((function(e){return e&&e(t)}))}}}function l(){return Math.random().toString(36).substr(2,8)}function f(e){var t=e.pathname,n=void 0===t?"/":t,r=e.search,o=void 0===r?"":r,a=e.hash,u=void 0===a?"":a;return o&&"?"!==o&&(n+="?"===o.charAt(0)?o:"?"+o),u&&"#"!==u&&(n+="#"===u.charAt(0)?u:"#"+u),n}function h(e){var t={};if(e){var n=e.indexOf("#");n>=0&&(t.hash=e.substr(n),e=e.substr(0,n));var r=e.indexOf("?");r>=0&&(t.search=e.substr(r),e=e.substr(0,r)),e&&(t.pathname=e)}return t}const p=window.wp.url,d=function(e){void 0===e&&(e={});var t=e.window,n=void 0===t?document.defaultView:t,p=n.history;function d(){var e=n.location,t=e.pathname,r=e.search,o=e.hash,u=p.state||{};return[u.idx,a({pathname:t,search:r,hash:o,state:u.usr||null,key:u.key||"default"})]}var v=null;n.addEventListener(i,(function(){if(v)P.call(v),v=null;else{var e=o.Pop,t=d(),n=t[0],r=t[1];if(P.length){if(null!=n){var a=w-n;a&&(v={action:e,location:r,retry:function(){x(-1*a)}},x(a))}}else j(e)}}));var y=o.Pop,g=d(),w=g[0],b=g[1],m=s(),P=s();function O(e){return"string"==typeof e?e:f(e)}function k(e,t){return void 0===t&&(t=null),a(r({pathname:b.pathname,hash:"",search:""},"string"==typeof e?h(e):e,{state:t,key:l()}))}function A(e,t){return[{usr:e.state,key:e.key,idx:t},O(e)]}function S(e,t,n){return!P.length||(P.call({action:e,location:t,retry:n}),!1)}function j(e){y=e;var t=d();w=t[0],b=t[1],m.call({action:y,location:b})}function x(e){p.go(e)}null==w&&(w=0,p.replaceState(r({},p.state,{idx:w}),""));var E={get action(){return y},get location(){return b},createHref:O,push:function e(t,r){var a=o.Push,u=k(t,r);if(S(a,u,(function(){e(t,r)}))){var i=A(u,w+1),c=i[0],s=i[1];try{p.pushState(c,"",s)}catch(e){n.location.assign(s)}j(a)}},replace:function e(t,n){var r=o.Replace,a=k(t,n);if(S(r,a,(function(){e(t,n)}))){var u=A(a,w),i=u[0],c=u[1];p.replaceState(i,"",c),j(r)}},go:x,back:function(){x(-1)},forward:function(){x(1)},listen:function(e){return m.push(e)},block:function(e){var t=P.push(e);return 1===P.length&&n.addEventListener(u,c),function(){t(),P.length||n.removeEventListener(u,c)}}};return E}(),v=d.push,y=d.replace;d.push=function(e,t){const n=(0,p.getQueryArgs)(window.location.href),r=(0,p.removeQueryArgs)(window.location.href,...Object.keys(n)),o=(0,p.addQueryArgs)(r,e);return v.call(d,o,t)},d.replace=function(e,t){const n=(0,p.getQueryArgs)(window.location.href),r=(0,p.removeQueryArgs)(window.location.href,...Object.keys(n)),o=(0,p.addQueryArgs)(r,e);return y.call(d,o,t)};const g=d,w=(0,n.createContext)(),b=(0,n.createContext)();function m(e){const t=new URLSearchParams(e.search);return{...e,params:Object.fromEntries(t.entries())}}const P=window.wp.privateApis,{lock:O,unlock:k}=(0,P.__dangerousOptInToUnstableAPIsOnlyForCoreModules)("I know using unstable features means my plugin or theme will inevitably break on the next WordPress release.","@wordpress/router"),A={};O(A,{useHistory:function(){return(0,n.useContext)(b)},useLocation:function(){return(0,n.useContext)(w)},RouterProvider:function({children:e}){const[t,r]=(0,n.useState)((()=>m(g.location)));return(0,n.useEffect)((()=>g.listen((({location:e})=>{r(m(e))}))),[]),(0,n.createElement)(b.Provider,{value:g},(0,n.createElement)(w.Provider,{value:t},e))}}),(window.wp=window.wp||{}).router=t})();