| 1 |
/******/ (() => { // webpackBootstrap |
| 2 |
/******/ "use strict"; |
| 3 |
/******/ // The require scope |
| 4 |
/******/ var __webpack_require__ = {}; |
| 5 |
/******/ |
| 6 |
/************************************************************************/ |
| 7 |
/******/ /* webpack/runtime/define property getters */ |
| 8 |
/******/ (() => { |
| 9 |
/******/ // define getter functions for harmony exports |
| 10 |
/******/ __webpack_require__.d = (exports, definition) => { |
| 11 |
/******/ for(var key in definition) { |
| 12 |
/******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) { |
| 13 |
/******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] }); |
| 14 |
/******/ } |
| 15 |
/******/ } |
| 16 |
/******/ }; |
| 17 |
/******/ })(); |
| 18 |
/******/ |
| 19 |
/******/ /* webpack/runtime/hasOwnProperty shorthand */ |
| 20 |
/******/ (() => { |
| 21 |
/******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop)) |
| 22 |
/******/ })(); |
| 23 |
/******/ |
| 24 |
/******/ /* webpack/runtime/make namespace object */ |
| 25 |
/******/ (() => { |
| 26 |
/******/ // define __esModule on exports |
| 27 |
/******/ __webpack_require__.r = (exports) => { |
| 28 |
/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) { |
| 29 |
/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); |
| 30 |
/******/ } |
| 31 |
/******/ Object.defineProperty(exports, '__esModule', { value: true }); |
| 32 |
/******/ }; |
| 33 |
/******/ })(); |
| 34 |
/******/ |
| 35 |
/************************************************************************/ |
| 36 |
var __webpack_exports__ = {}; |
| 37 |
// ESM COMPAT FLAG |
| 38 |
__webpack_require__.r(__webpack_exports__); |
| 39 |
|
| 40 |
// EXPORTS |
| 41 |
__webpack_require__.d(__webpack_exports__, { |
| 42 |
"privateApis": () => (/* reexport */ privateApis) |
| 43 |
}); |
| 44 |
|
| 45 |
;// CONCATENATED MODULE: external ["wp","element"] |
| 46 |
const external_wp_element_namespaceObject = window["wp"]["element"]; |
| 47 |
;// CONCATENATED MODULE: ./node_modules/@babel/runtime/helpers/esm/extends.js |
| 48 |
function extends_extends() { |
| 49 |
extends_extends = Object.assign ? Object.assign.bind() : function (target) { |
| 50 |
for (var i = 1; i < arguments.length; i++) { |
| 51 |
var source = arguments[i]; |
| 52 |
for (var key in source) { |
| 53 |
if (Object.prototype.hasOwnProperty.call(source, key)) { |
| 54 |
target[key] = source[key]; |
| 55 |
} |
| 56 |
} |
| 57 |
} |
| 58 |
return target; |
| 59 |
}; |
| 60 |
return extends_extends.apply(this, arguments); |
| 61 |
} |
| 62 |
;// CONCATENATED MODULE: ./node_modules/history/index.js |
| 63 |
var r,B=r||(r={});B.Pop="POP";B.Push="PUSH";B.Replace="REPLACE";var C= false?0:function(b){return b};function D(b,h){if(!b){"undefined"!==typeof console&&console.warn(h);try{throw Error(h);}catch(k){}}}function E(b){b.preventDefault();b.returnValue=""} |
| 64 |
function F(){var b=[];return{get length(){return b.length},push:function(h){b.push(h);return function(){b=b.filter(function(k){return k!==h})}},call:function(h){b.forEach(function(k){return k&&k(h)})}}}function H(){return Math.random().toString(36).substr(2,8)}function I(b){var h=b.pathname,k=b.search;b=b.hash;return(void 0===h?"/":h)+(void 0===k?"":k)+(void 0===b?"":b)} |
| 65 |
function J(b){var h={};if(b){var k=b.indexOf("#");0<=k&&(h.hash=b.substr(k),b=b.substr(0,k));k=b.indexOf("?");0<=k&&(h.search=b.substr(k),b=b.substr(0,k));b&&(h.pathname=b)}return h} |
| 66 |
function createBrowserHistory(b){function h(){var c=p.location,a=m.state||{};return[a.idx,C({pathname:c.pathname,search:c.search,hash:c.hash,state:a.usr||null,key:a.key||"default"})]}function k(c){return"string"===typeof c?c:I(c)}function x(c,a){void 0===a&&(a=null);return C(extends_extends({pathname:q.pathname,hash:"",search:""},"string"===typeof c?J(c):c,{state:a,key:H()}))}function z(c){t=c;c=h();v=c[0];q=c[1];d.call({action:t,location:q})}function A(c,a){function e(){A(c,a)}var l=r.Push,g=x(c, |
| 67 |
a);if(!f.length||(f.call({action:l,location:g,retry:e}),!1)){var n=[{usr:g.state,key:g.key,idx:v+1},k(g)];g=n[0];n=n[1];try{m.pushState(g,"",n)}catch(G){p.location.assign(n)}z(l)}}function y(c,a){function e(){y(c,a)}var l=r.Replace,g=x(c,a);f.length&&(f.call({action:l,location:g,retry:e}),1)||(g=[{usr:g.state,key:g.key,idx:v},k(g)],m.replaceState(g[0],"",g[1]),z(l))}function w(c){m.go(c)}void 0===b&&(b={});b=b.window;var p=void 0===b?document.defaultView:b,m=p.history,u=null;p.addEventListener("popstate", |
| 68 |
function(){if(u)f.call(u),u=null;else{var c=r.Pop,a=h(),e=a[0];a=a[1];if(f.length)if(null!=e){var l=v-e;l&&(u={action:c,location:a,retry:function(){w(-1*l)}},w(l))}else false?0: |
| 69 |
void 0;else z(c)}});var t=r.Pop;b=h();var v=b[0],q=b[1],d=F(),f=F();null==v&&(v=0,m.replaceState(extends_extends({},m.state,{idx:v}),""));return{get action(){return t},get location(){return q},createHref:k,push:A,replace:y,go:w,back:function(){w(-1)},forward:function(){w(1)},listen:function(c){return d.push(c)},block:function(c){var a=f.push(c);1===f.length&&p.addEventListener("beforeunload",E);return function(){a();f.length||p.removeEventListener("beforeunload",E)}}}}; |
| 70 |
function createHashHistory(b){function h(){var a=J(m.location.hash.substr(1)),e=a.pathname,l=a.search;a=a.hash;var g=u.state||{};return[g.idx,C({pathname:void 0===e?"/":e,search:void 0===l?"":l,hash:void 0===a?"":a,state:g.usr||null,key:g.key||"default"})]}function k(){if(t)c.call(t),t=null;else{var a=r.Pop,e=h(),l=e[0];e=e[1];if(c.length)if(null!=l){var g=q-l;g&&(t={action:a,location:e,retry:function(){p(-1*g)}},p(g))}else false?0: |
| 71 |
void 0;else A(a)}}function x(a){var e=document.querySelector("base"),l="";e&&e.getAttribute("href")&&(e=m.location.href,l=e.indexOf("#"),l=-1===l?e:e.slice(0,l));return l+"#"+("string"===typeof a?a:I(a))}function z(a,e){void 0===e&&(e=null);return C(_extends({pathname:d.pathname,hash:"",search:""},"string"===typeof a?J(a):a,{state:e,key:H()}))}function A(a){v=a;a=h();q=a[0];d=a[1];f.call({action:v,location:d})}function y(a,e){function l(){y(a,e)}var g=r.Push,n=z(a,e); false? |
| 72 |
0:void 0;if(!c.length||(c.call({action:g,location:n,retry:l}),!1)){var G=[{usr:n.state,key:n.key,idx:q+1},x(n)];n=G[0];G=G[1];try{u.pushState(n,"",G)}catch(K){m.location.assign(G)}A(g)}}function w(a,e){function l(){w(a,e)}var g=r.Replace,n=z(a,e); false?0:void 0;c.length&&(c.call({action:g,location:n,retry:l}),1)||(n=[{usr:n.state,key:n.key,idx:q},x(n)],u.replaceState(n[0],"",n[1]),A(g))}function p(a){u.go(a)}void 0===b&&(b={});b=b.window;var m=void 0===b?document.defaultView:b,u=m.history,t=null;m.addEventListener("popstate",k);m.addEventListener("hashchange",function(){var a=h()[1];I(a)!==I(d)&&k()});var v=r.Pop;b=h();var q=b[0],d=b[1],f=F(),c=F();null==q&&(q=0,u.replaceState(_extends({},u.state,{idx:q}),""));return{get action(){return v},get location(){return d}, |
| 73 |
createHref:x,push:y,replace:w,go:p,back:function(){p(-1)},forward:function(){p(1)},listen:function(a){return f.push(a)},block:function(a){var e=c.push(a);1===c.length&&m.addEventListener("beforeunload",E);return function(){e();c.length||m.removeEventListener("beforeunload",E)}}}}; |
| 74 |
function createMemoryHistory(b){function h(d,f){void 0===f&&(f=null);return C(_extends({pathname:t.pathname,search:"",hash:""},"string"===typeof d?J(d):d,{state:f,key:H()}))}function k(d,f,c){return!q.length||(q.call({action:d,location:f,retry:c}),!1)}function x(d,f){u=d;t=f;v.call({action:u,location:t})}function z(d,f){var c=r.Push,a=h(d,f); false?0: |
| 75 |
void 0;k(c,a,function(){z(d,f)})&&(m+=1,p.splice(m,p.length,a),x(c,a))}function A(d,f){var c=r.Replace,a=h(d,f); false?0:void 0;k(c,a,function(){A(d,f)})&&(p[m]=a,x(c,a))}function y(d){var f=Math.min(Math.max(m+d,0),p.length-1),c=r.Pop,a=p[f];k(c,a,function(){y(d)})&&(m=f,x(c,a))}void 0===b&&(b={});var w=b;b=w.initialEntries;w=w.initialIndex;var p=(void 0=== |
| 76 |
b?["/"]:b).map(function(d){var f=C(_extends({pathname:"/",search:"",hash:"",state:null,key:H()},"string"===typeof d?J(d):d)); false?0:void 0;return f}),m=Math.min(Math.max(null==w?p.length-1:w,0),p.length-1),u=r.Pop,t=p[m],v=F(),q=F();return{get index(){return m},get action(){return u},get location(){return t},createHref:function(d){return"string"=== |
| 77 |
typeof d?d:I(d)},push:z,replace:A,go:y,back:function(){y(-1)},forward:function(){y(1)},listen:function(d){return v.push(d)},block:function(d){return q.push(d)}}}; |
| 78 |
|
| 79 |
;// CONCATENATED MODULE: external ["wp","url"] |
| 80 |
const external_wp_url_namespaceObject = window["wp"]["url"]; |
| 81 |
;// CONCATENATED MODULE: ./packages/router/build-module/history.js |
| 82 |
/** |
| 83 |
* External dependencies |
| 84 |
*/ |
| 85 |
|
| 86 |
|
| 87 |
/** |
| 88 |
* WordPress dependencies |
| 89 |
*/ |
| 90 |
|
| 91 |
const history_history = createBrowserHistory(); |
| 92 |
const originalHistoryPush = history_history.push; |
| 93 |
const originalHistoryReplace = history_history.replace; |
| 94 |
function push(params, state) { |
| 95 |
const currentArgs = (0,external_wp_url_namespaceObject.getQueryArgs)(window.location.href); |
| 96 |
const currentUrlWithoutArgs = (0,external_wp_url_namespaceObject.removeQueryArgs)(window.location.href, ...Object.keys(currentArgs)); |
| 97 |
const newUrl = (0,external_wp_url_namespaceObject.addQueryArgs)(currentUrlWithoutArgs, params); |
| 98 |
return originalHistoryPush.call(history_history, newUrl, state); |
| 99 |
} |
| 100 |
function replace(params, state) { |
| 101 |
const currentArgs = (0,external_wp_url_namespaceObject.getQueryArgs)(window.location.href); |
| 102 |
const currentUrlWithoutArgs = (0,external_wp_url_namespaceObject.removeQueryArgs)(window.location.href, ...Object.keys(currentArgs)); |
| 103 |
const newUrl = (0,external_wp_url_namespaceObject.addQueryArgs)(currentUrlWithoutArgs, params); |
| 104 |
return originalHistoryReplace.call(history_history, newUrl, state); |
| 105 |
} |
| 106 |
history_history.push = push; |
| 107 |
history_history.replace = replace; |
| 108 |
/* harmony default export */ const build_module_history = (history_history); |
| 109 |
|
| 110 |
;// CONCATENATED MODULE: ./packages/router/build-module/router.js |
| 111 |
|
| 112 |
/** |
| 113 |
* WordPress dependencies |
| 114 |
*/ |
| 115 |
|
| 116 |
|
| 117 |
/** |
| 118 |
* Internal dependencies |
| 119 |
*/ |
| 120 |
|
| 121 |
const RoutesContext = (0,external_wp_element_namespaceObject.createContext)(); |
| 122 |
const HistoryContext = (0,external_wp_element_namespaceObject.createContext)(); |
| 123 |
function useLocation() { |
| 124 |
return (0,external_wp_element_namespaceObject.useContext)(RoutesContext); |
| 125 |
} |
| 126 |
function useHistory() { |
| 127 |
return (0,external_wp_element_namespaceObject.useContext)(HistoryContext); |
| 128 |
} |
| 129 |
function getLocationWithParams(location) { |
| 130 |
const searchParams = new URLSearchParams(location.search); |
| 131 |
return { |
| 132 |
...location, |
| 133 |
params: Object.fromEntries(searchParams.entries()) |
| 134 |
}; |
| 135 |
} |
| 136 |
function RouterProvider({ |
| 137 |
children |
| 138 |
}) { |
| 139 |
const [location, setLocation] = (0,external_wp_element_namespaceObject.useState)(() => getLocationWithParams(build_module_history.location)); |
| 140 |
(0,external_wp_element_namespaceObject.useEffect)(() => { |
| 141 |
return build_module_history.listen(({ |
| 142 |
location: updatedLocation |
| 143 |
}) => { |
| 144 |
setLocation(getLocationWithParams(updatedLocation)); |
| 145 |
}); |
| 146 |
}, []); |
| 147 |
return (0,external_wp_element_namespaceObject.createElement)(HistoryContext.Provider, { |
| 148 |
value: build_module_history |
| 149 |
}, (0,external_wp_element_namespaceObject.createElement)(RoutesContext.Provider, { |
| 150 |
value: location |
| 151 |
}, children)); |
| 152 |
} |
| 153 |
|
| 154 |
;// CONCATENATED MODULE: external ["wp","privateApis"] |
| 155 |
const external_wp_privateApis_namespaceObject = window["wp"]["privateApis"]; |
| 156 |
;// CONCATENATED MODULE: ./packages/router/build-module/lock-unlock.js |
| 157 |
/** |
| 158 |
* WordPress dependencies |
| 159 |
*/ |
| 160 |
|
| 161 |
const { |
| 162 |
lock, |
| 163 |
unlock |
| 164 |
} = (0,external_wp_privateApis_namespaceObject.__dangerousOptInToUnstableAPIsOnlyForCoreModules)('I know using unstable features means my plugin or theme will inevitably break on the next WordPress release.', '@wordpress/router'); |
| 165 |
|
| 166 |
;// CONCATENATED MODULE: ./packages/router/build-module/private-apis.js |
| 167 |
/** |
| 168 |
* Internal dependencies |
| 169 |
*/ |
| 170 |
|
| 171 |
|
| 172 |
const privateApis = {}; |
| 173 |
lock(privateApis, { |
| 174 |
useHistory: useHistory, |
| 175 |
useLocation: useLocation, |
| 176 |
RouterProvider: RouterProvider |
| 177 |
}); |
| 178 |
|
| 179 |
;// CONCATENATED MODULE: ./packages/router/build-module/index.js |
| 180 |
|
| 181 |
|
| 182 |
(window.wp = window.wp || {}).router = __webpack_exports__; |
| 183 |
/******/ })() |
| 184 |
; |