From 1736b10b1e38eebe746cd43b83913e689d955f2d Mon Sep 17 00:00:00 2001 From: Jon Surrell Date: Thu, 26 Sep 2024 12:15:22 +1000 Subject: [PATCH] Update to use a11y script module package in Core. (#65539) Update the interactivity-router package to use the @wordpress/a11y module for its aria-live regions. This was behind a Gutenberg-only flag. Since the a11y module is landing in Core in 6.7, the flag can be removed to always use the a11y module. See https://github.com/WordPress/wordpress-develop/pull/7304. Source: https://github.com/WordPress/gutenberg/commit/20ae57d7326f28fdd39ae7d9566919f2c800a6f8 --- build-module/assets.php | 2 +- build-module/interactivity-router/index.js | 21 +++++++++++-------- .../interactivity-router/index.min.js | 2 +- .../interactivity-router/index.min.js.map | 2 +- gutenberg.php | 2 +- 5 files changed, 16 insertions(+), 13 deletions(-) diff --git a/build-module/assets.php b/build-module/assets.php index 43353eb3..d712fc59 100644 --- a/build-module/assets.php +++ b/build-module/assets.php @@ -1 +1 @@ - array('dependencies' => array(), 'version' => '25c9ec16abe91b62e906', 'type' => 'module'), 'block-library/file/view.min.js' => array('dependencies' => array('@wordpress/interactivity'), 'version' => '0600eabcab185ceb0430', 'type' => 'module'), 'block-library/image/view.min.js' => array('dependencies' => array('@wordpress/interactivity'), 'version' => 'e90ba1f1006920e85ee5', 'type' => 'module'), 'block-library/navigation/view.min.js' => array('dependencies' => array('@wordpress/interactivity'), 'version' => '7b370e821516feba4955', 'type' => 'module'), 'block-library/query/view.min.js' => array('dependencies' => array('@wordpress/interactivity', array('id' => '@wordpress/interactivity-router', 'import' => 'dynamic')), 'version' => '1100711c4bda188467ac', 'type' => 'module'), 'block-library/search/view.min.js' => array('dependencies' => array('@wordpress/interactivity'), 'version' => '69851b7ac418d6ef7967', 'type' => 'module'), 'interactivity/index.min.js' => array('dependencies' => array(), 'version' => '5f35b6d3bd962e6e82b5', 'type' => 'module'), 'interactivity/debug.min.js' => array('dependencies' => array(), 'version' => 'b78f5dee01439db66197', 'type' => 'module'), 'interactivity-router/index.min.js' => array('dependencies' => array('@wordpress/interactivity', array('id' => '@wordpress/a11y', 'import' => 'dynamic')), 'version' => '67c16aba5bbfcdd72f9a', 'type' => 'module')); + array('dependencies' => array(), 'version' => '25c9ec16abe91b62e906', 'type' => 'module'), 'block-library/file/view.min.js' => array('dependencies' => array('@wordpress/interactivity'), 'version' => '0600eabcab185ceb0430', 'type' => 'module'), 'block-library/image/view.min.js' => array('dependencies' => array('@wordpress/interactivity'), 'version' => 'e90ba1f1006920e85ee5', 'type' => 'module'), 'block-library/navigation/view.min.js' => array('dependencies' => array('@wordpress/interactivity'), 'version' => '7b370e821516feba4955', 'type' => 'module'), 'block-library/query/view.min.js' => array('dependencies' => array('@wordpress/interactivity', array('id' => '@wordpress/interactivity-router', 'import' => 'dynamic')), 'version' => '1100711c4bda188467ac', 'type' => 'module'), 'block-library/search/view.min.js' => array('dependencies' => array('@wordpress/interactivity'), 'version' => '69851b7ac418d6ef7967', 'type' => 'module'), 'interactivity/index.min.js' => array('dependencies' => array(), 'version' => '5f35b6d3bd962e6e82b5', 'type' => 'module'), 'interactivity/debug.min.js' => array('dependencies' => array(), 'version' => 'b78f5dee01439db66197', 'type' => 'module'), 'interactivity-router/index.min.js' => array('dependencies' => array('@wordpress/interactivity', array('id' => '@wordpress/a11y', 'import' => 'dynamic')), 'version' => '61e34d2019d119e32785', 'type' => 'module')); diff --git a/build-module/interactivity-router/index.js b/build-module/interactivity-router/index.js index a94d336c..a84685c4 100644 --- a/build-module/interactivity-router/index.js +++ b/build-module/interactivity-router/index.js @@ -305,8 +305,7 @@ const { url: window.location.href, navigation: { hasStarted: false, - hasFinished: false, - message: '' + hasFinished: false } }, actions: { @@ -455,22 +454,26 @@ function a11ySpeak(messageKey) { } catch {} } else { // Fallback to localized strings from Interactivity API state. + // @todo This block is for Core < 6.7.0. Remove when support is dropped. + + // @ts-expect-error if (state.navigation.texts?.loading) { + // @ts-expect-error navigationTexts.loading = state.navigation.texts.loading; } + // @ts-expect-error if (state.navigation.texts?.loaded) { + // @ts-expect-error navigationTexts.loaded = state.navigation.texts.loaded; } } } const message = navigationTexts[messageKey]; - if (true) { - Promise.resolve(/* import() */).then(__webpack_require__.bind(__webpack_require__, 105)).then(({ - speak - }) => speak(message), - // Ignore failures to load the a11y module. - () => {}); - } else {} + Promise.resolve(/* import() */).then(__webpack_require__.bind(__webpack_require__, 105)).then(({ + speak + }) => speak(message), + // Ignore failures to load the a11y module. + () => {}); } // Add click and prefetch to all links. diff --git a/build-module/interactivity-router/index.min.js b/build-module/interactivity-router/index.min.js index e818beda..d84ec66f 100644 --- a/build-module/interactivity-router/index.min.js +++ b/build-module/interactivity-router/index.min.js @@ -1,2 +1,2 @@ -import*as e from"@wordpress/interactivity";var t,o,a,r,n={343:(e,t,o)=>{o.d(t,{B:()=>a,J:()=>r});const a=async e=>{const t=e=>e.id||e.outerHTML,o=new Map;for(const a of e)o.set(t(a),a);const a=[];for(const e of document.head.children){const r=t(e);"LINK"===e.nodeName||"STYLE"===e.nodeName?a.push(e):o.has(r)?o.delete(r):"SCRIPT"!==e.nodeName&&"META"!==e.nodeName&&a.push(e)}const r=[...o.values()];a.forEach((e=>e.remove())),document.head.append(...r)},r=async(e,t)=>{const o=[],a=[{tagName:"style",selector:"link[rel=stylesheet]",attribute:"href"},{tagName:"script",selector:"script[src]",attribute:"src"}];for(const r of a){const{tagName:a,selector:n,attribute:i}=r,s=e.querySelectorAll(n);await Promise.all(Array.from(s).map((async r=>{const n=r.getAttribute(i);if(!t.has(n))try{const e=await fetch(n),o=await e.text();t.set(n,{tag:r,text:o})}catch(e){console.error(e)}const s=t.get(n),c=e.createElement(a);c.innerText=s.text;for(const e of s.tag.attributes)c.setAttribute(e.name,e.value);o.push(c)})))}return[e.querySelector("title"),...e.querySelectorAll("style"),...o]}},126:(e,t,o)=>{o.a(e,(async(e,a)=>{try{o.d(t,{N:()=>k,S:()=>L});var r,n=o(998),i=o(343);const{directivePrefix:s,getRegionRootFragment:c,initialVdom:l,toVdom:d,render:u,parseServerData:g,populateServerData:p,batch:f}=(0,n.privateApis)("I acknowledge that using private APIs means my theme or plugin will inevitably break in the next version of WordPress."),h=null!==(r=(0,n.getConfig)("core/router").navigationMode)&&void 0!==r?r:"regionBased",m=new Map,w=new Map,y=e=>{const t=new URL(e,window.location.href);return t.pathname+t.search},v=async(e,{html:t})=>{try{if(!t){const o=await window.fetch(e);if(200!==o.status)return!1;t=await o.text()}const o=(new window.DOMParser).parseFromString(t,"text/html");return b(o)}catch(e){return!1}},b=async(e,{vdom:t}={})=>{const o={body:void 0};let a;if("fullPage"===h&&(a=await(0,i.J)(e,w),o.body=t?t.get(document.body):d(e.body)),"regionBased"===h){const a=`data-${s}-router-region`;e.querySelectorAll(`[${a}]`).forEach((e=>{const r=e.getAttribute(a);o[r]=t?.has(e)?t.get(e):d(e)}))}const r=e.querySelector("title")?.innerText,n=g(e);return{regions:o,head:a,title:r,initialData:n}},S=e=>{f((()=>{if("fullPage"===h){(0,i.B)(e.head);const t=c(document.body);u(e.regions.body,t)}if("regionBased"===h){p(e.initialData);const t=`data-${s}-router-region`;document.querySelectorAll(`[${t}]`).forEach((o=>{const a=o.getAttribute(t),r=c(o);u(e.regions[a],r)}))}e.title&&(document.title=e.title)}))},x=e=>(window.location.assign(e),new Promise((()=>{})));window.addEventListener("popstate",(async()=>{const e=y(window.location.href),t=m.has(e)&&await m.get(e);t?(S(t),L.url=window.location.href):window.location.reload()})),"fullPage"===h&&([].map.call(document.querySelectorAll("script[src]"),(e=>{w.set(e.getAttribute("src"),{tag:e,text:e.textContent})})),await(0,i.J)(document,w)),m.set(y(window.location.href),Promise.resolve(b(document,{vdom:l})));const P=e=>e&&e instanceof window.HTMLAnchorElement&&e.href&&(!e.target||"_self"===e.target)&&e.origin===window.location.origin&&!e.pathname.startsWith("/wp-admin")&&!e.pathname.startsWith("/wp-login.php")&&!e.getAttribute("href").startsWith("#")&&!new URL(e.href).searchParams.has("_wpnonce"),A=e=>e&&0===e.button&&!e.metaKey&&!e.ctrlKey&&!e.altKey&&!e.shiftKey&&!e.defaultPrevented;let _="",N=!1;const E={loading:"Loading page, please wait.",loaded:"Page Loaded."},{state:L,actions:k}=(0,n.store)("core/router",{state:{url:window.location.href,navigation:{hasStarted:!1,hasFinished:!1,message:""}},actions:{*navigate(e,t={}){const{clientNavigationDisabled:o}=(0,n.getConfig)();o&&(yield x(e));const a=y(e),{navigation:r}=L,{loadingAnimation:i=!0,screenReaderAnnouncement:s=!0,timeout:c=1e4}=t;_=e,k.prefetch(a,t);const l=new Promise((e=>setTimeout(e,c))),d=setTimeout((()=>{_===e&&(i&&(r.hasStarted=!0,r.hasFinished=!1),s&&q("loading"))}),400),u=yield Promise.race([m.get(a),l]);if(clearTimeout(d),_===e)if(u&&!u.initialData?.config?.["core/router"]?.clientNavigationDisabled){yield S(u),window.history[t.replace?"replaceState":"pushState"]({},"",e),L.url=e,i&&(r.hasStarted=!1,r.hasFinished=!0),s&&q("loaded");const{hash:o}=new URL(e,window.location.href);o&&document.querySelector(o)?.scrollIntoView()}else yield x(e)},prefetch(e,t={}){const{clientNavigationDisabled:o}=(0,n.getConfig)();if(o)return;const a=y(e);!t.force&&m.has(a)||m.set(a,v(a,{html:t.html}))}}});function q(e){if(!N){N=!0;const e=document.getElementById("wp-script-module-data-@wordpress/interactivity-router")?.textContent;if(e)try{const t=JSON.parse(e);"string"==typeof t?.i18n?.loading&&(E.loading=t.i18n.loading),"string"==typeof t?.i18n?.loaded&&(E.loaded=t.i18n.loaded)}catch{}else L.navigation.texts?.loading&&(E.loading=L.navigation.texts.loading),L.navigation.texts?.loaded&&(E.loaded=L.navigation.texts.loaded)}const t=E[e];Promise.resolve().then(o.bind(o,105)).then((({speak:e})=>e(t)),(()=>{}))}"fullPage"===h&&(document.addEventListener("click",(function(e){const t=e.target.closest("a");P(t)&&A(e)&&(e.preventDefault(),k.navigate(t.href))}),!0),document.addEventListener("mouseenter",(function(e){if("A"===e.target?.nodeName){const t=e.target.closest("a");P(t)&&A(e)&&k.prefetch(t.href)}}),!0)),a()}catch(D){a(D)}}),1)},105:e=>{e.exports=import("@wordpress/a11y")},998:(t,o,a)=>{var r,n;t.exports=(r={getConfig:()=>e.getConfig,privateApis:()=>e.privateApis,store:()=>e.store},n={},a.d(n,r),n)}},i={};function s(e){var t=i[e];if(void 0!==t)return t.exports;var o=i[e]={exports:{}};return n[e](o,o.exports,s),o.exports}t="function"==typeof Symbol?Symbol("webpack queues"):"__webpack_queues__",o="function"==typeof Symbol?Symbol("webpack exports"):"__webpack_exports__",a="function"==typeof Symbol?Symbol("webpack error"):"__webpack_error__",r=e=>{e&&e.d<1&&(e.d=1,e.forEach((e=>e.r--)),e.forEach((e=>e.r--?e.r++:e())))},s.a=(e,n,i)=>{var s;i&&((s=[]).d=-1);var c,l,d,u=new Set,g=e.exports,p=new Promise(((e,t)=>{d=t,l=e}));p[o]=g,p[t]=e=>(s&&e(s),u.forEach(e),p.catch((e=>{}))),e.exports=p,n((e=>{var n;c=(e=>e.map((e=>{if(null!==e&&"object"==typeof e){if(e[t])return e;if(e.then){var n=[];n.d=0,e.then((e=>{i[o]=e,r(n)}),(e=>{i[a]=e,r(n)}));var i={};return i[t]=e=>e(n),i}}var s={};return s[t]=e=>{},s[o]=e,s})))(e);var i=()=>c.map((e=>{if(e[a])throw e[a];return e[o]})),l=new Promise((e=>{(n=()=>e(i)).r=0;var o=e=>e!==s&&!u.has(e)&&(u.add(e),e&&!e.d&&(n.r++,e.push(n)));c.map((e=>e[t](o)))}));return n.r?l:i()}),(e=>(e?d(p[a]=e):l(g),r(s)))),s&&s.d<0&&(s.d=0)},s.d=(e,t)=>{for(var o in t)s.o(t,o)&&!s.o(e,o)&&Object.defineProperty(e,o,{enumerable:!0,get:t[o]})},s.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t);var c=s(126),l=(c=await c).N,d=c.S;export{l as actions,d as state}; +import*as e from"@wordpress/interactivity";var t,o,a,r,n={343:(e,t,o)=>{o.d(t,{B:()=>a,J:()=>r});const a=async e=>{const t=e=>e.id||e.outerHTML,o=new Map;for(const a of e)o.set(t(a),a);const a=[];for(const e of document.head.children){const r=t(e);"LINK"===e.nodeName||"STYLE"===e.nodeName?a.push(e):o.has(r)?o.delete(r):"SCRIPT"!==e.nodeName&&"META"!==e.nodeName&&a.push(e)}const r=[...o.values()];a.forEach((e=>e.remove())),document.head.append(...r)},r=async(e,t)=>{const o=[],a=[{tagName:"style",selector:"link[rel=stylesheet]",attribute:"href"},{tagName:"script",selector:"script[src]",attribute:"src"}];for(const r of a){const{tagName:a,selector:n,attribute:i}=r,s=e.querySelectorAll(n);await Promise.all(Array.from(s).map((async r=>{const n=r.getAttribute(i);if(!t.has(n))try{const e=await fetch(n),o=await e.text();t.set(n,{tag:r,text:o})}catch(e){console.error(e)}const s=t.get(n),c=e.createElement(a);c.innerText=s.text;for(const e of s.tag.attributes)c.setAttribute(e.name,e.value);o.push(c)})))}return[e.querySelector("title"),...e.querySelectorAll("style"),...o]}},126:(e,t,o)=>{o.a(e,(async(e,a)=>{try{o.d(t,{N:()=>k,S:()=>L});var r,n=o(998),i=o(343);const{directivePrefix:s,getRegionRootFragment:c,initialVdom:l,toVdom:d,render:u,parseServerData:p,populateServerData:f,batch:g}=(0,n.privateApis)("I acknowledge that using private APIs means my theme or plugin will inevitably break in the next version of WordPress."),h=null!==(r=(0,n.getConfig)("core/router").navigationMode)&&void 0!==r?r:"regionBased",m=new Map,w=new Map,y=e=>{const t=new URL(e,window.location.href);return t.pathname+t.search},v=async(e,{html:t})=>{try{if(!t){const o=await window.fetch(e);if(200!==o.status)return!1;t=await o.text()}const o=(new window.DOMParser).parseFromString(t,"text/html");return b(o)}catch(e){return!1}},b=async(e,{vdom:t}={})=>{const o={body:void 0};let a;if("fullPage"===h&&(a=await(0,i.J)(e,w),o.body=t?t.get(document.body):d(e.body)),"regionBased"===h){const a=`data-${s}-router-region`;e.querySelectorAll(`[${a}]`).forEach((e=>{const r=e.getAttribute(a);o[r]=t?.has(e)?t.get(e):d(e)}))}const r=e.querySelector("title")?.innerText,n=p(e);return{regions:o,head:a,title:r,initialData:n}},S=e=>{g((()=>{if("fullPage"===h){(0,i.B)(e.head);const t=c(document.body);u(e.regions.body,t)}if("regionBased"===h){f(e.initialData);const t=`data-${s}-router-region`;document.querySelectorAll(`[${t}]`).forEach((o=>{const a=o.getAttribute(t),r=c(o);u(e.regions[a],r)}))}e.title&&(document.title=e.title)}))},x=e=>(window.location.assign(e),new Promise((()=>{})));window.addEventListener("popstate",(async()=>{const e=y(window.location.href),t=m.has(e)&&await m.get(e);t?(S(t),L.url=window.location.href):window.location.reload()})),"fullPage"===h&&([].map.call(document.querySelectorAll("script[src]"),(e=>{w.set(e.getAttribute("src"),{tag:e,text:e.textContent})})),await(0,i.J)(document,w)),m.set(y(window.location.href),Promise.resolve(b(document,{vdom:l})));const P=e=>e&&e instanceof window.HTMLAnchorElement&&e.href&&(!e.target||"_self"===e.target)&&e.origin===window.location.origin&&!e.pathname.startsWith("/wp-admin")&&!e.pathname.startsWith("/wp-login.php")&&!e.getAttribute("href").startsWith("#")&&!new URL(e.href).searchParams.has("_wpnonce"),A=e=>e&&0===e.button&&!e.metaKey&&!e.ctrlKey&&!e.altKey&&!e.shiftKey&&!e.defaultPrevented;let _="",N=!1;const E={loading:"Loading page, please wait.",loaded:"Page Loaded."},{state:L,actions:k}=(0,n.store)("core/router",{state:{url:window.location.href,navigation:{hasStarted:!1,hasFinished:!1}},actions:{*navigate(e,t={}){const{clientNavigationDisabled:o}=(0,n.getConfig)();o&&(yield x(e));const a=y(e),{navigation:r}=L,{loadingAnimation:i=!0,screenReaderAnnouncement:s=!0,timeout:c=1e4}=t;_=e,k.prefetch(a,t);const l=new Promise((e=>setTimeout(e,c))),d=setTimeout((()=>{_===e&&(i&&(r.hasStarted=!0,r.hasFinished=!1),s&&q("loading"))}),400),u=yield Promise.race([m.get(a),l]);if(clearTimeout(d),_===e)if(u&&!u.initialData?.config?.["core/router"]?.clientNavigationDisabled){yield S(u),window.history[t.replace?"replaceState":"pushState"]({},"",e),L.url=e,i&&(r.hasStarted=!1,r.hasFinished=!0),s&&q("loaded");const{hash:o}=new URL(e,window.location.href);o&&document.querySelector(o)?.scrollIntoView()}else yield x(e)},prefetch(e,t={}){const{clientNavigationDisabled:o}=(0,n.getConfig)();if(o)return;const a=y(e);!t.force&&m.has(a)||m.set(a,v(a,{html:t.html}))}}});function q(e){if(!N){N=!0;const e=document.getElementById("wp-script-module-data-@wordpress/interactivity-router")?.textContent;if(e)try{const t=JSON.parse(e);"string"==typeof t?.i18n?.loading&&(E.loading=t.i18n.loading),"string"==typeof t?.i18n?.loaded&&(E.loaded=t.i18n.loaded)}catch{}else L.navigation.texts?.loading&&(E.loading=L.navigation.texts.loading),L.navigation.texts?.loaded&&(E.loaded=L.navigation.texts.loaded)}const t=E[e];Promise.resolve().then(o.bind(o,105)).then((({speak:e})=>e(t)),(()=>{}))}"fullPage"===h&&(document.addEventListener("click",(function(e){const t=e.target.closest("a");P(t)&&A(e)&&(e.preventDefault(),k.navigate(t.href))}),!0),document.addEventListener("mouseenter",(function(e){if("A"===e.target?.nodeName){const t=e.target.closest("a");P(t)&&A(e)&&k.prefetch(t.href)}}),!0)),a()}catch(D){a(D)}}),1)},105:e=>{e.exports=import("@wordpress/a11y")},998:(t,o,a)=>{var r,n;t.exports=(r={getConfig:()=>e.getConfig,privateApis:()=>e.privateApis,store:()=>e.store},n={},a.d(n,r),n)}},i={};function s(e){var t=i[e];if(void 0!==t)return t.exports;var o=i[e]={exports:{}};return n[e](o,o.exports,s),o.exports}t="function"==typeof Symbol?Symbol("webpack queues"):"__webpack_queues__",o="function"==typeof Symbol?Symbol("webpack exports"):"__webpack_exports__",a="function"==typeof Symbol?Symbol("webpack error"):"__webpack_error__",r=e=>{e&&e.d<1&&(e.d=1,e.forEach((e=>e.r--)),e.forEach((e=>e.r--?e.r++:e())))},s.a=(e,n,i)=>{var s;i&&((s=[]).d=-1);var c,l,d,u=new Set,p=e.exports,f=new Promise(((e,t)=>{d=t,l=e}));f[o]=p,f[t]=e=>(s&&e(s),u.forEach(e),f.catch((e=>{}))),e.exports=f,n((e=>{var n;c=(e=>e.map((e=>{if(null!==e&&"object"==typeof e){if(e[t])return e;if(e.then){var n=[];n.d=0,e.then((e=>{i[o]=e,r(n)}),(e=>{i[a]=e,r(n)}));var i={};return i[t]=e=>e(n),i}}var s={};return s[t]=e=>{},s[o]=e,s})))(e);var i=()=>c.map((e=>{if(e[a])throw e[a];return e[o]})),l=new Promise((e=>{(n=()=>e(i)).r=0;var o=e=>e!==s&&!u.has(e)&&(u.add(e),e&&!e.d&&(n.r++,e.push(n)));c.map((e=>e[t](o)))}));return n.r?l:i()}),(e=>(e?d(f[a]=e):l(p),r(s)))),s&&s.d<0&&(s.d=0)},s.d=(e,t)=>{for(var o in t)s.o(t,o)&&!s.o(e,o)&&Object.defineProperty(e,o,{enumerable:!0,get:t[o]})},s.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t);var c=s(126),l=(c=await c).N,d=c.S;export{l as actions,d as state}; //# sourceMappingURL=index.min.js.map \ No newline at end of file diff --git a/build-module/interactivity-router/index.min.js.map b/build-module/interactivity-router/index.min.js.map index afa4fdd8..1fdba996 100644 --- a/build-module/interactivity-router/index.min.js.map +++ b/build-module/interactivity-router/index.min.js.map @@ -1 +1 @@ -{"version":3,"file":"interactivity-router/index.min.js","mappings":"+CAAIA,EACAC,EACAC,EACAC,E,0CCGG,MAAMC,EAAaC,UAEzB,MAAMC,EAAaC,GAAkBA,EAAIC,IAAMD,EAAIE,UAG7CC,EAAa,IAAIC,IACvB,IAAM,MAAMC,KAASC,EACpBH,EAAWI,IAAKR,EAAUM,GAASA,GAGpC,MAAMG,EAAsB,GAG5B,IAAM,MAAMH,KAASI,SAASC,KAAKC,SAAW,CAC7C,MAAMV,EAAKF,EAAUM,GAEG,SAAnBA,EAAMO,UAA0C,UAAnBP,EAAMO,SACvCJ,EAASK,KAAMR,GACJF,EAAWW,IAAKb,GAC3BE,EAAWY,OAAQd,GACW,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AOC,eAAetC,EAASmC,EAAK,CAAEI,YAAY,EAAM9J,IAAKyJ,EAAWC,IAE1E,ECND9B,EAAoB+B,EAAI,CAACV,EAAKc,IAAUH,OAAOI,UAAUC,eAAexG,KAAKwF,EAAKc,GCGlF,IAAIG,EAAsBtC,EAAoB,K","sources":["webpack://wp/webpack/runtime/async module","webpack://wp/./packages/interactivity-router/build-module/@wordpress/interactivity-router/src/head.ts","webpack://wp/./packages/interactivity-router/build-module/@wordpress/interactivity-router/src/index.ts","webpack://wp/external import \"@wordpress/a11y\"","webpack://wp/external module \"@wordpress/interactivity\"","webpack://wp/webpack/bootstrap","webpack://wp/webpack/runtime/define property getters","webpack://wp/webpack/runtime/hasOwnProperty shorthand","webpack://wp/webpack/startup"],"sourcesContent":["var webpackQueues = typeof Symbol === \"function\" ? Symbol(\"webpack queues\") : \"__webpack_queues__\";\nvar webpackExports = typeof Symbol === \"function\" ? Symbol(\"webpack exports\") : \"__webpack_exports__\";\nvar webpackError = typeof Symbol === \"function\" ? Symbol(\"webpack error\") : \"__webpack_error__\";\nvar resolveQueue = (queue) => {\n\tif(queue && queue.d < 1) {\n\t\tqueue.d = 1;\n\t\tqueue.forEach((fn) => (fn.r--));\n\t\tqueue.forEach((fn) => (fn.r-- ? fn.r++ : fn()));\n\t}\n}\nvar wrapDeps = (deps) => (deps.map((dep) => {\n\tif(dep !== null && typeof dep === \"object\") {\n\t\tif(dep[webpackQueues]) return dep;\n\t\tif(dep.then) {\n\t\t\tvar queue = [];\n\t\t\tqueue.d = 0;\n\t\t\tdep.then((r) => {\n\t\t\t\tobj[webpackExports] = r;\n\t\t\t\tresolveQueue(queue);\n\t\t\t}, (e) => {\n\t\t\t\tobj[webpackError] = e;\n\t\t\t\tresolveQueue(queue);\n\t\t\t});\n\t\t\tvar obj = {};\n\t\t\tobj[webpackQueues] = (fn) => (fn(queue));\n\t\t\treturn obj;\n\t\t}\n\t}\n\tvar ret = {};\n\tret[webpackQueues] = x => {};\n\tret[webpackExports] = dep;\n\treturn ret;\n}));\n__webpack_require__.a = (module, body, hasAwait) => {\n\tvar queue;\n\thasAwait && ((queue = []).d = -1);\n\tvar depQueues = new Set();\n\tvar exports = module.exports;\n\tvar currentDeps;\n\tvar outerResolve;\n\tvar reject;\n\tvar promise = new Promise((resolve, rej) => {\n\t\treject = rej;\n\t\touterResolve = resolve;\n\t});\n\tpromise[webpackExports] = exports;\n\tpromise[webpackQueues] = (fn) => (queue && fn(queue), depQueues.forEach(fn), promise[\"catch\"](x => {}));\n\tmodule.exports = promise;\n\tbody((deps) => {\n\t\tcurrentDeps = wrapDeps(deps);\n\t\tvar fn;\n\t\tvar getResult = () => (currentDeps.map((d) => {\n\t\t\tif(d[webpackError]) throw d[webpackError];\n\t\t\treturn d[webpackExports];\n\t\t}))\n\t\tvar promise = new Promise((resolve) => {\n\t\t\tfn = () => (resolve(getResult));\n\t\t\tfn.r = 0;\n\t\t\tvar fnQueue = (q) => (q !== queue && !depQueues.has(q) && (depQueues.add(q), q && !q.d && (fn.r++, q.push(fn))));\n\t\t\tcurrentDeps.map((dep) => (dep[webpackQueues](fnQueue)));\n\t\t});\n\t\treturn fn.r ? promise : getResult();\n\t}, (err) => ((err ? reject(promise[webpackError] = err) : outerResolve(exports)), resolveQueue(queue)));\n\tqueue && queue.d < 0 && (queue.d = 0);\n};","/**\n * Helper to update only the necessary tags in the head.\n *\n * @async\n * @param newHead The head elements of the new page.\n */\nexport const updateHead = async ( newHead: HTMLHeadElement[] ) => {\n\t// Helper to get the tag id store in the cache.\n\tconst getTagId = ( tag: Element ) => tag.id || tag.outerHTML;\n\n\t// Map incoming head tags by their content.\n\tconst newHeadMap = new Map< string, Element >();\n\tfor ( const child of newHead ) {\n\t\tnewHeadMap.set( getTagId( child ), child );\n\t}\n\n\tconst toRemove: Element[] = [];\n\n\t// Detect nodes that should be added or removed.\n\tfor ( const child of document.head.children ) {\n\t\tconst id = getTagId( child );\n\t\t// Always remove styles and links as they might change.\n\t\tif ( child.nodeName === 'LINK' || child.nodeName === 'STYLE' ) {\n\t\t\ttoRemove.push( child );\n\t\t} else if ( newHeadMap.has( id ) ) {\n\t\t\tnewHeadMap.delete( id );\n\t\t} else if ( child.nodeName !== 'SCRIPT' && child.nodeName !== 'META' ) {\n\t\t\ttoRemove.push( child );\n\t\t}\n\t}\n\n\t// Prepare new assets.\n\tconst toAppend = [ ...newHeadMap.values() ];\n\n\t// Apply the changes.\n\ttoRemove.forEach( ( n ) => n.remove() );\n\tdocument.head.append( ...toAppend );\n};\n\n/**\n * Fetches and processes head assets (stylesheets and scripts) from a specified document.\n *\n * @async\n * @param doc The document from which to fetch head assets. It should support standard DOM querying methods.\n * @param headElements A map of head elements to modify tracking the URLs of already processed assets to avoid duplicates.\n * @param headElements.tag\n * @param headElements.text\n *\n * @return Returns an array of HTML elements representing the head assets.\n */\nexport const fetchHeadAssets = async (\n\tdoc: Document,\n\theadElements: Map< string, { tag: HTMLElement; text: string } >\n): Promise< HTMLElement[] > => {\n\tconst headTags = [];\n\tconst assets = [\n\t\t{\n\t\t\ttagName: 'style',\n\t\t\tselector: 'link[rel=stylesheet]',\n\t\t\tattribute: 'href',\n\t\t},\n\t\t{ tagName: 'script', selector: 'script[src]', attribute: 'src' },\n\t];\n\tfor ( const asset of assets ) {\n\t\tconst { tagName, selector, attribute } = asset;\n\t\tconst tags = doc.querySelectorAll<\n\t\t\tHTMLScriptElement | HTMLStyleElement\n\t\t>( selector );\n\n\t\t// Use Promise.all to wait for fetch to complete\n\t\tawait Promise.all(\n\t\t\tArray.from( tags ).map( async ( tag ) => {\n\t\t\t\tconst attributeValue = tag.getAttribute( attribute );\n\t\t\t\tif ( ! headElements.has( attributeValue ) ) {\n\t\t\t\t\ttry {\n\t\t\t\t\t\tconst response = await fetch( attributeValue );\n\t\t\t\t\t\tconst text = await response.text();\n\t\t\t\t\t\theadElements.set( attributeValue, {\n\t\t\t\t\t\t\ttag,\n\t\t\t\t\t\t\ttext,\n\t\t\t\t\t\t} );\n\t\t\t\t\t} catch ( e ) {\n\t\t\t\t\t\t// eslint-disable-next-line no-console\n\t\t\t\t\t\tconsole.error( e );\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tconst headElement = headElements.get( attributeValue );\n\t\t\t\tconst element = doc.createElement( tagName );\n\t\t\t\telement.innerText = headElement.text;\n\t\t\t\tfor ( const attr of headElement.tag.attributes ) {\n\t\t\t\t\telement.setAttribute( attr.name, attr.value );\n\t\t\t\t}\n\t\t\t\theadTags.push( element );\n\t\t\t} )\n\t\t);\n\t}\n\n\treturn [\n\t\tdoc.querySelector( 'title' ),\n\t\t...doc.querySelectorAll( 'style' ),\n\t\t...headTags,\n\t];\n};\n","/**\n * WordPress dependencies\n */\nimport { store, privateApis, getConfig } from '@wordpress/interactivity';\n\n/**\n * Internal dependencies\n */\nimport { fetchHeadAssets, updateHead } from './head';\n\nconst {\n\tdirectivePrefix,\n\tgetRegionRootFragment,\n\tinitialVdom,\n\ttoVdom,\n\trender,\n\tparseServerData,\n\tpopulateServerData,\n\tbatch,\n} = privateApis(\n\t'I acknowledge that using private APIs means my theme or plugin will inevitably break in the next version of WordPress.'\n);\n\ninterface NavigateOptions {\n\tforce?: boolean;\n\thtml?: string;\n\treplace?: boolean;\n\ttimeout?: number;\n\tloadingAnimation?: boolean;\n\tscreenReaderAnnouncement?: boolean;\n}\n\ninterface PrefetchOptions {\n\tforce?: boolean;\n\thtml?: string;\n}\n\ninterface VdomParams {\n\tvdom?: typeof initialVdom;\n}\n\ninterface Page {\n\tregions: Record< string, any >;\n\thead: HTMLHeadElement[];\n\ttitle: string;\n\tinitialData: any;\n}\n\ntype RegionsToVdom = ( dom: Document, params?: VdomParams ) => Promise< Page >;\n\n// Check if the navigation mode is full page or region based.\nconst navigationMode: 'regionBased' | 'fullPage' =\n\tgetConfig( 'core/router' ).navigationMode ?? 'regionBased';\n\n// The cache of visited and prefetched pages, stylesheets and scripts.\nconst pages = new Map< string, Promise< Page | false > >();\nconst headElements = new Map< string, { tag: HTMLElement; text: string } >();\n\n// Helper to remove domain and hash from the URL. We are only interesting in\n// caching the path and the query.\nconst getPagePath = ( url: string ) => {\n\tconst u = new URL( url, window.location.href );\n\treturn u.pathname + u.search;\n};\n\n// Fetch a new page and convert it to a static virtual DOM.\nconst fetchPage = async ( url: string, { html }: { html: string } ) => {\n\ttry {\n\t\tif ( ! html ) {\n\t\t\tconst res = await window.fetch( url );\n\t\t\tif ( res.status !== 200 ) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\thtml = await res.text();\n\t\t}\n\t\tconst dom = new window.DOMParser().parseFromString( html, 'text/html' );\n\t\treturn regionsToVdom( dom );\n\t} catch ( e ) {\n\t\treturn false;\n\t}\n};\n\n// Return an object with VDOM trees of those HTML regions marked with a\n// `router-region` directive.\nconst regionsToVdom: RegionsToVdom = async ( dom, { vdom } = {} ) => {\n\tconst regions = { body: undefined };\n\tlet head: HTMLElement[];\n\tif ( globalThis.IS_GUTENBERG_PLUGIN ) {\n\t\tif ( navigationMode === 'fullPage' ) {\n\t\t\thead = await fetchHeadAssets( dom, headElements );\n\t\t\tregions.body = vdom\n\t\t\t\t? vdom.get( document.body )\n\t\t\t\t: toVdom( dom.body );\n\t\t}\n\t}\n\tif ( navigationMode === 'regionBased' ) {\n\t\tconst attrName = `data-${ directivePrefix }-router-region`;\n\t\tdom.querySelectorAll( `[${ attrName }]` ).forEach( ( region ) => {\n\t\t\tconst id = region.getAttribute( attrName );\n\t\t\tregions[ id ] = vdom?.has( region )\n\t\t\t\t? vdom.get( region )\n\t\t\t\t: toVdom( region );\n\t\t} );\n\t}\n\tconst title = dom.querySelector( 'title' )?.innerText;\n\tconst initialData = parseServerData( dom );\n\treturn { regions, head, title, initialData };\n};\n\n// Render all interactive regions contained in the given page.\nconst renderRegions = ( page: Page ) => {\n\tbatch( () => {\n\t\tif ( globalThis.IS_GUTENBERG_PLUGIN ) {\n\t\t\tif ( navigationMode === 'fullPage' ) {\n\t\t\t\t// Once this code is tested and more mature, the head should be updated for region based navigation as well.\n\t\t\t\tupdateHead( page.head );\n\t\t\t\tconst fragment = getRegionRootFragment( document.body );\n\t\t\t\trender( page.regions.body, fragment );\n\t\t\t}\n\t\t}\n\t\tif ( navigationMode === 'regionBased' ) {\n\t\t\tpopulateServerData( page.initialData );\n\t\t\tconst attrName = `data-${ directivePrefix }-router-region`;\n\t\t\tdocument\n\t\t\t\t.querySelectorAll( `[${ attrName }]` )\n\t\t\t\t.forEach( ( region ) => {\n\t\t\t\t\tconst id = region.getAttribute( attrName );\n\t\t\t\t\tconst fragment = getRegionRootFragment( region );\n\t\t\t\t\trender( page.regions[ id ], fragment );\n\t\t\t\t} );\n\t\t}\n\t\tif ( page.title ) {\n\t\t\tdocument.title = page.title;\n\t\t}\n\t} );\n};\n\n/**\n * Load the given page forcing a full page reload.\n *\n * The function returns a promise that won't resolve, useful to prevent any\n * potential feedback indicating that the navigation has finished while the new\n * page is being loaded.\n *\n * @param href The page href.\n * @return Promise that never resolves.\n */\nconst forcePageReload = ( href: string ) => {\n\twindow.location.assign( href );\n\treturn new Promise( () => {} );\n};\n\n// Listen to the back and forward buttons and restore the page if it's in the\n// cache.\nwindow.addEventListener( 'popstate', async () => {\n\tconst pagePath = getPagePath( window.location.href ); // Remove hash.\n\tconst page = pages.has( pagePath ) && ( await pages.get( pagePath ) );\n\tif ( page ) {\n\t\trenderRegions( page );\n\t\t// Update the URL in the state.\n\t\tstate.url = window.location.href;\n\t} else {\n\t\twindow.location.reload();\n\t}\n} );\n\n// Initialize the router and cache the initial page using the initial vDOM.\n// Once this code is tested and more mature, the head should be updated for\n// region based navigation as well.\nif ( globalThis.IS_GUTENBERG_PLUGIN ) {\n\tif ( navigationMode === 'fullPage' ) {\n\t\t// Cache the scripts. Has to be called before fetching the assets.\n\t\t[].map.call( document.querySelectorAll( 'script[src]' ), ( script ) => {\n\t\t\theadElements.set( script.getAttribute( 'src' ), {\n\t\t\t\ttag: script,\n\t\t\t\ttext: script.textContent,\n\t\t\t} );\n\t\t} );\n\t\tawait fetchHeadAssets( document, headElements );\n\t}\n}\npages.set(\n\tgetPagePath( window.location.href ),\n\tPromise.resolve( regionsToVdom( document, { vdom: initialVdom } ) )\n);\n\n// Check if the link is valid for client-side navigation.\nconst isValidLink = ( ref: HTMLAnchorElement ) =>\n\tref &&\n\tref instanceof window.HTMLAnchorElement &&\n\tref.href &&\n\t( ! ref.target || ref.target === '_self' ) &&\n\tref.origin === window.location.origin &&\n\t! ref.pathname.startsWith( '/wp-admin' ) &&\n\t! ref.pathname.startsWith( '/wp-login.php' ) &&\n\t! ref.getAttribute( 'href' ).startsWith( '#' ) &&\n\t! new URL( ref.href ).searchParams.has( '_wpnonce' );\n\n// Check if the event is valid for client-side navigation.\nconst isValidEvent = ( event: MouseEvent ) =>\n\tevent &&\n\tevent.button === 0 && // Left clicks only.\n\t! event.metaKey && // Open in new tab (Mac).\n\t! event.ctrlKey && // Open in new tab (Windows).\n\t! event.altKey && // Download.\n\t! event.shiftKey &&\n\t! event.defaultPrevented;\n\n// Variable to store the current navigation.\nlet navigatingTo = '';\n\nlet hasLoadedNavigationTextsData = false;\nconst navigationTexts = {\n\tloading: 'Loading page, please wait.',\n\tloaded: 'Page Loaded.',\n};\n\ninterface Store {\n\tstate: {\n\t\turl: string;\n\t\tnavigation: {\n\t\t\thasStarted: boolean;\n\t\t\thasFinished: boolean;\n\t\t\tmessage: string;\n\t\t\ttexts?: {\n\t\t\t\tloading?: string;\n\t\t\t\tloaded?: string;\n\t\t\t};\n\t\t};\n\t};\n\tactions: {\n\t\tnavigate: ( href: string, options?: NavigateOptions ) => void;\n\t\tprefetch: ( url: string, options?: PrefetchOptions ) => void;\n\t};\n}\n\nexport const { state, actions } = store< Store >( 'core/router', {\n\tstate: {\n\t\turl: window.location.href,\n\t\tnavigation: {\n\t\t\thasStarted: false,\n\t\t\thasFinished: false,\n\t\t\tmessage: '',\n\t\t},\n\t},\n\tactions: {\n\t\t/**\n\t\t * Navigates to the specified page.\n\t\t *\n\t\t * This function normalizes the passed href, fetchs the page HTML if\n\t\t * needed, and updates any interactive regions whose contents have\n\t\t * changed. It also creates a new entry in the browser session history.\n\t\t *\n\t\t * @param href The page href.\n\t\t * @param [options] Options object.\n\t\t * @param [options.force] If true, it forces re-fetching the URL.\n\t\t * @param [options.html] HTML string to be used instead of fetching the requested URL.\n\t\t * @param [options.replace] If true, it replaces the current entry in the browser session history.\n\t\t * @param [options.timeout] Time until the navigation is aborted, in milliseconds. Default is 10000.\n\t\t * @param [options.loadingAnimation] Whether an animation should be shown while navigating. Default to `true`.\n\t\t * @param [options.screenReaderAnnouncement] Whether a message for screen readers should be announced while navigating. Default to `true`.\n\t\t *\n\t\t * @return Promise that resolves once the navigation is completed or aborted.\n\t\t */\n\t\t*navigate( href: string, options: NavigateOptions = {} ) {\n\t\t\tconst { clientNavigationDisabled } = getConfig();\n\t\t\tif ( clientNavigationDisabled ) {\n\t\t\t\tyield forcePageReload( href );\n\t\t\t}\n\n\t\t\tconst pagePath = getPagePath( href );\n\t\t\tconst { navigation } = state;\n\t\t\tconst {\n\t\t\t\tloadingAnimation = true,\n\t\t\t\tscreenReaderAnnouncement = true,\n\t\t\t\ttimeout = 10000,\n\t\t\t} = options;\n\n\t\t\tnavigatingTo = href;\n\t\t\tactions.prefetch( pagePath, options );\n\n\t\t\t// Create a promise that resolves when the specified timeout ends.\n\t\t\t// The timeout value is 10 seconds by default.\n\t\t\tconst timeoutPromise = new Promise< void >( ( resolve ) =>\n\t\t\t\tsetTimeout( resolve, timeout )\n\t\t\t);\n\n\t\t\t// Don't update the navigation status immediately, wait 400 ms.\n\t\t\tconst loadingTimeout = setTimeout( () => {\n\t\t\t\tif ( navigatingTo !== href ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tif ( loadingAnimation ) {\n\t\t\t\t\tnavigation.hasStarted = true;\n\t\t\t\t\tnavigation.hasFinished = false;\n\t\t\t\t}\n\t\t\t\tif ( screenReaderAnnouncement ) {\n\t\t\t\t\ta11ySpeak( 'loading' );\n\t\t\t\t}\n\t\t\t}, 400 );\n\n\t\t\tconst page = yield Promise.race( [\n\t\t\t\tpages.get( pagePath ),\n\t\t\t\ttimeoutPromise,\n\t\t\t] );\n\n\t\t\t// Dismiss loading message if it hasn't been added yet.\n\t\t\tclearTimeout( loadingTimeout );\n\n\t\t\t// Once the page is fetched, the destination URL could have changed\n\t\t\t// (e.g., by clicking another link in the meantime). If so, bail\n\t\t\t// out, and let the newer execution to update the HTML.\n\t\t\tif ( navigatingTo !== href ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif (\n\t\t\t\tpage &&\n\t\t\t\t! page.initialData?.config?.[ 'core/router' ]\n\t\t\t\t\t?.clientNavigationDisabled\n\t\t\t) {\n\t\t\t\tyield renderRegions( page );\n\t\t\t\twindow.history[\n\t\t\t\t\toptions.replace ? 'replaceState' : 'pushState'\n\t\t\t\t]( {}, '', href );\n\n\t\t\t\t// Update the URL in the state.\n\t\t\t\tstate.url = href;\n\n\t\t\t\t// Update the navigation status once the the new page rendering\n\t\t\t\t// has been completed.\n\t\t\t\tif ( loadingAnimation ) {\n\t\t\t\t\tnavigation.hasStarted = false;\n\t\t\t\t\tnavigation.hasFinished = true;\n\t\t\t\t}\n\n\t\t\t\tif ( screenReaderAnnouncement ) {\n\t\t\t\t\ta11ySpeak( 'loaded' );\n\t\t\t\t}\n\n\t\t\t\t// Scroll to the anchor if exits in the link.\n\t\t\t\tconst { hash } = new URL( href, window.location.href );\n\t\t\t\tif ( hash ) {\n\t\t\t\t\tdocument.querySelector( hash )?.scrollIntoView();\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tyield forcePageReload( href );\n\t\t\t}\n\t\t},\n\n\t\t/**\n\t\t * Prefetchs the page with the passed URL.\n\t\t *\n\t\t * The function normalizes the URL and stores internally the fetch\n\t\t * promise, to avoid triggering a second fetch for an ongoing request.\n\t\t *\n\t\t * @param url The page URL.\n\t\t * @param [options] Options object.\n\t\t * @param [options.force] Force fetching the URL again.\n\t\t * @param [options.html] HTML string to be used instead of fetching the requested URL.\n\t\t */\n\t\tprefetch( url: string, options: PrefetchOptions = {} ) {\n\t\t\tconst { clientNavigationDisabled } = getConfig();\n\t\t\tif ( clientNavigationDisabled ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst pagePath = getPagePath( url );\n\t\t\tif ( options.force || ! pages.has( pagePath ) ) {\n\t\t\t\tpages.set(\n\t\t\t\t\tpagePath,\n\t\t\t\t\tfetchPage( pagePath, { html: options.html } )\n\t\t\t\t);\n\t\t\t}\n\t\t},\n\t},\n} );\n\n/**\n * Announces a message to screen readers.\n *\n * This is a wrapper around the `@wordpress/a11y` package's `speak` function. It handles importing\n * the package on demand and should be used instead of calling `ally.speak` direacly.\n *\n * @param messageKey The message to be announced by assistive technologies.\n */\nfunction a11ySpeak( messageKey: keyof typeof navigationTexts ) {\n\tif ( ! hasLoadedNavigationTextsData ) {\n\t\thasLoadedNavigationTextsData = true;\n\t\tconst content = document.getElementById(\n\t\t\t'wp-script-module-data-@wordpress/interactivity-router'\n\t\t)?.textContent;\n\t\tif ( content ) {\n\t\t\ttry {\n\t\t\t\tconst parsed = JSON.parse( content );\n\t\t\t\tif ( typeof parsed?.i18n?.loading === 'string' ) {\n\t\t\t\t\tnavigationTexts.loading = parsed.i18n.loading;\n\t\t\t\t}\n\t\t\t\tif ( typeof parsed?.i18n?.loaded === 'string' ) {\n\t\t\t\t\tnavigationTexts.loaded = parsed.i18n.loaded;\n\t\t\t\t}\n\t\t\t} catch {}\n\t\t} else {\n\t\t\t// Fallback to localized strings from Interactivity API state.\n\t\t\tif ( state.navigation.texts?.loading ) {\n\t\t\t\tnavigationTexts.loading = state.navigation.texts.loading;\n\t\t\t}\n\t\t\tif ( state.navigation.texts?.loaded ) {\n\t\t\t\tnavigationTexts.loaded = state.navigation.texts.loaded;\n\t\t\t}\n\t\t}\n\t}\n\n\tconst message = navigationTexts[ messageKey ];\n\n\tif ( globalThis.IS_GUTENBERG_PLUGIN ) {\n\t\timport( '@wordpress/a11y' ).then(\n\t\t\t( { speak } ) => speak( message ),\n\t\t\t// Ignore failures to load the a11y module.\n\t\t\t() => {}\n\t\t);\n\t} else {\n\t\tstate.navigation.message =\n\t\t\t// Announce that the page has been loaded. If the message is the\n\t\t\t// same, we use a no-break space similar to the @wordpress/a11y\n\t\t\t// package: https://github.com/WordPress/gutenberg/blob/c395242b8e6ee20f8b06c199e4fc2920d7018af1/packages/a11y/src/filter-message.js#L20-L26\n\t\t\tmessage + ( state.navigation.message === message ? '\\u00A0' : '' );\n\t}\n}\n\n// Add click and prefetch to all links.\nif ( globalThis.IS_GUTENBERG_PLUGIN ) {\n\tif ( navigationMode === 'fullPage' ) {\n\t\t// Navigate on click.\n\t\tdocument.addEventListener(\n\t\t\t'click',\n\t\t\tfunction ( event ) {\n\t\t\t\tconst ref = ( event.target as Element ).closest( 'a' );\n\t\t\t\tif ( isValidLink( ref ) && isValidEvent( event ) ) {\n\t\t\t\t\tevent.preventDefault();\n\t\t\t\t\tactions.navigate( ref.href );\n\t\t\t\t}\n\t\t\t},\n\t\t\ttrue\n\t\t);\n\t\t// Prefetch on hover.\n\t\tdocument.addEventListener(\n\t\t\t'mouseenter',\n\t\t\tfunction ( event ) {\n\t\t\t\tif ( ( event.target as Element )?.nodeName === 'A' ) {\n\t\t\t\t\tconst ref = ( event.target as Element ).closest( 'a' );\n\t\t\t\t\tif ( isValidLink( ref ) && isValidEvent( event ) ) {\n\t\t\t\t\t\tactions.prefetch( ref.href );\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t},\n\t\t\ttrue\n\t\t);\n\t}\n}\n","module.exports = import(\"@wordpress/a11y\");;","var x = y => { var x = {}; __webpack_require__.d(x, y); return x; }\nvar y = x => () => x\nmodule.exports = x({ [\"getConfig\"]: () => __WEBPACK_EXTERNAL_MODULE__wordpress_interactivity_8e89b257__.getConfig, [\"privateApis\"]: () => __WEBPACK_EXTERNAL_MODULE__wordpress_interactivity_8e89b257__.privateApis, [\"store\"]: () => __WEBPACK_EXTERNAL_MODULE__wordpress_interactivity_8e89b257__.store });","// The module cache\nvar __webpack_module_cache__ = {};\n\n// The require function\nfunction __webpack_require__(moduleId) {\n\t// Check if module is in cache\n\tvar cachedModule = __webpack_module_cache__[moduleId];\n\tif (cachedModule !== undefined) {\n\t\treturn cachedModule.exports;\n\t}\n\t// Create a new module (and put it into the cache)\n\tvar module = __webpack_module_cache__[moduleId] = {\n\t\t// no module.id needed\n\t\t// no module.loaded needed\n\t\texports: {}\n\t};\n\n\t// Execute the module function\n\t__webpack_modules__[moduleId](module, module.exports, __webpack_require__);\n\n\t// Return the exports of the module\n\treturn module.exports;\n}\n\n","// define getter functions for harmony exports\n__webpack_require__.d = (exports, definition) => {\n\tfor(var key in definition) {\n\t\tif(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n\t\t\tObject.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n\t\t}\n\t}\n};","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))","// startup\n// Load entry module and return exports\n// This entry module used 'module' so it can't be inlined\nvar __webpack_exports__ = __webpack_require__(126);\n"],"names":["webpackQueues","webpackExports","webpackError","resolveQueue","updateHead","async","getTagId","tag","id","outerHTML","newHeadMap","Map","child","newHead","set","toRemove","document","head","children","nodeName","push","has","delete","toAppend","values","forEach","n","remove","append","fetchHeadAssets","doc","headElements","headTags","assets","tagName","selector","attribute","asset","tags","querySelectorAll","Promise","all","Array","from","map","attributeValue","getAttribute","response","fetch","text","e","console","error","headElement","get","element","createElement","innerText","attr","attributes","setAttribute","name","value","querySelector","directivePrefix","getRegionRootFragment","initialVdom","toVdom","render","parseServerData","populateServerData","batch","privateApis","navigationMode","_getConfig$navigation","getConfig","pages","getPagePath","url","u","URL","window","location","href","pathname","search","fetchPage","html","res","status","dom","DOMParser","parseFromString","regionsToVdom","vdom","regions","body","undefined","attrName","region","title","initialData","renderRegions","page","fragment","forcePageReload","assign","addEventListener","pagePath","state","reload","call","script","textContent","resolve","isValidLink","ref","HTMLAnchorElement","target","origin","startsWith","searchParams","isValidEvent","event","button","metaKey","ctrlKey","altKey","shiftKey","defaultPrevented","navigatingTo","hasLoadedNavigationTextsData","navigationTexts","loading","loaded","actions","store","navigation","hasStarted","hasFinished","message","navigate","options","clientNavigationDisabled","loadingAnimation","screenReaderAnnouncement","timeout","prefetch","timeoutPromise","setTimeout","loadingTimeout","a11ySpeak","race","clearTimeout","config","history","replace","hash","scrollIntoView","force","messageKey","content","getElementById","parsed","JSON","parse","i18n","texts","then","speak","closest","preventDefault","module","exports","import","y","x","__WEBPACK_EXTERNAL_MODULE__wordpress_interactivity_8e89b257__","__webpack_require__","d","__webpack_module_cache__","moduleId","cachedModule","__webpack_modules__","Symbol","queue","fn","r","a","hasAwait","currentDeps","outerResolve","reject","depQueues","Set","promise","rej","deps","dep","obj","ret","wrapDeps","getResult","fnQueue","q","add","err","definition","key","o","Object","defineProperty","enumerable","prop","prototype","hasOwnProperty","__webpack_exports__"],"sourceRoot":""} \ No newline at end of file +{"version":3,"file":"interactivity-router/index.min.js","mappings":"+CAAIA,EACAC,EACAC,EACAC,E,0CCGG,MAAMC,EAAaC,UAEzB,MAAMC,EAAaC,GAAkBA,EAAIC,IAAMD,EAAIE,UAG7CC,EAAa,IAAIC,IACvB,IAAM,MAAMC,KAASC,EACpBH,EAAWI,IAAKR,EAAUM,GAASA,GAGpC,MAAMG,EAAsB,GAG5B,IAAM,MAAMH,KAASI,SAASC,KAAKC,SAAW,CAC7C,MAAMV,EAAKF,EAAUM,GAEG,SAAnBA,EAAMO,UAA0C,UAAnBP,EAAMO,SACvCJ,EAASK,KAAMR,GACJF,EAAWW,IAAKb,GAC3BE,EAAWY,OAAQd,GACW,WAAnBI,EAAMO,UAA4C,SAAnBP,EAAMO,UAChDJ,EAASK,KAAMR,EAEjB,CAGA,MAAMW,EAAW,IAAKb,EAAWc,UAGjCT,EAASU,SAAWC,GAAO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,KAAKwF,EAAKc,GCGlF,IAAIG,EAAsBtC,EAAoB,K","sources":["webpack://wp/webpack/runtime/async module","webpack://wp/./packages/interactivity-router/build-module/@wordpress/interactivity-router/src/head.ts","webpack://wp/./packages/interactivity-router/build-module/@wordpress/interactivity-router/src/index.ts","webpack://wp/external import \"@wordpress/a11y\"","webpack://wp/external module \"@wordpress/interactivity\"","webpack://wp/webpack/bootstrap","webpack://wp/webpack/runtime/define property getters","webpack://wp/webpack/runtime/hasOwnProperty shorthand","webpack://wp/webpack/startup"],"sourcesContent":["var webpackQueues = typeof Symbol === \"function\" ? Symbol(\"webpack queues\") : \"__webpack_queues__\";\nvar webpackExports = typeof Symbol === \"function\" ? Symbol(\"webpack exports\") : \"__webpack_exports__\";\nvar webpackError = typeof Symbol === \"function\" ? Symbol(\"webpack error\") : \"__webpack_error__\";\nvar resolveQueue = (queue) => {\n\tif(queue && queue.d < 1) {\n\t\tqueue.d = 1;\n\t\tqueue.forEach((fn) => (fn.r--));\n\t\tqueue.forEach((fn) => (fn.r-- ? fn.r++ : fn()));\n\t}\n}\nvar wrapDeps = (deps) => (deps.map((dep) => {\n\tif(dep !== null && typeof dep === \"object\") {\n\t\tif(dep[webpackQueues]) return dep;\n\t\tif(dep.then) {\n\t\t\tvar queue = [];\n\t\t\tqueue.d = 0;\n\t\t\tdep.then((r) => {\n\t\t\t\tobj[webpackExports] = r;\n\t\t\t\tresolveQueue(queue);\n\t\t\t}, (e) => {\n\t\t\t\tobj[webpackError] = e;\n\t\t\t\tresolveQueue(queue);\n\t\t\t});\n\t\t\tvar obj = {};\n\t\t\tobj[webpackQueues] = (fn) => (fn(queue));\n\t\t\treturn obj;\n\t\t}\n\t}\n\tvar ret = {};\n\tret[webpackQueues] = x => {};\n\tret[webpackExports] = dep;\n\treturn ret;\n}));\n__webpack_require__.a = (module, body, hasAwait) => {\n\tvar queue;\n\thasAwait && ((queue = []).d = -1);\n\tvar depQueues = new Set();\n\tvar exports = module.exports;\n\tvar currentDeps;\n\tvar outerResolve;\n\tvar reject;\n\tvar promise = new Promise((resolve, rej) => {\n\t\treject = rej;\n\t\touterResolve = resolve;\n\t});\n\tpromise[webpackExports] = exports;\n\tpromise[webpackQueues] = (fn) => (queue && fn(queue), depQueues.forEach(fn), promise[\"catch\"](x => {}));\n\tmodule.exports = promise;\n\tbody((deps) => {\n\t\tcurrentDeps = wrapDeps(deps);\n\t\tvar fn;\n\t\tvar getResult = () => (currentDeps.map((d) => {\n\t\t\tif(d[webpackError]) throw d[webpackError];\n\t\t\treturn d[webpackExports];\n\t\t}))\n\t\tvar promise = new Promise((resolve) => {\n\t\t\tfn = () => (resolve(getResult));\n\t\t\tfn.r = 0;\n\t\t\tvar fnQueue = (q) => (q !== queue && !depQueues.has(q) && (depQueues.add(q), q && !q.d && (fn.r++, q.push(fn))));\n\t\t\tcurrentDeps.map((dep) => (dep[webpackQueues](fnQueue)));\n\t\t});\n\t\treturn fn.r ? promise : getResult();\n\t}, (err) => ((err ? reject(promise[webpackError] = err) : outerResolve(exports)), resolveQueue(queue)));\n\tqueue && queue.d < 0 && (queue.d = 0);\n};","/**\n * Helper to update only the necessary tags in the head.\n *\n * @async\n * @param newHead The head elements of the new page.\n */\nexport const updateHead = async ( newHead: HTMLHeadElement[] ) => {\n\t// Helper to get the tag id store in the cache.\n\tconst getTagId = ( tag: Element ) => tag.id || tag.outerHTML;\n\n\t// Map incoming head tags by their content.\n\tconst newHeadMap = new Map< string, Element >();\n\tfor ( const child of newHead ) {\n\t\tnewHeadMap.set( getTagId( child ), child );\n\t}\n\n\tconst toRemove: Element[] = [];\n\n\t// Detect nodes that should be added or removed.\n\tfor ( const child of document.head.children ) {\n\t\tconst id = getTagId( child );\n\t\t// Always remove styles and links as they might change.\n\t\tif ( child.nodeName === 'LINK' || child.nodeName === 'STYLE' ) {\n\t\t\ttoRemove.push( child );\n\t\t} else if ( newHeadMap.has( id ) ) {\n\t\t\tnewHeadMap.delete( id );\n\t\t} else if ( child.nodeName !== 'SCRIPT' && child.nodeName !== 'META' ) {\n\t\t\ttoRemove.push( child );\n\t\t}\n\t}\n\n\t// Prepare new assets.\n\tconst toAppend = [ ...newHeadMap.values() ];\n\n\t// Apply the changes.\n\ttoRemove.forEach( ( n ) => n.remove() );\n\tdocument.head.append( ...toAppend );\n};\n\n/**\n * Fetches and processes head assets (stylesheets and scripts) from a specified document.\n *\n * @async\n * @param doc The document from which to fetch head assets. It should support standard DOM querying methods.\n * @param headElements A map of head elements to modify tracking the URLs of already processed assets to avoid duplicates.\n * @param headElements.tag\n * @param headElements.text\n *\n * @return Returns an array of HTML elements representing the head assets.\n */\nexport const fetchHeadAssets = async (\n\tdoc: Document,\n\theadElements: Map< string, { tag: HTMLElement; text: string } >\n): Promise< HTMLElement[] > => {\n\tconst headTags = [];\n\tconst assets = [\n\t\t{\n\t\t\ttagName: 'style',\n\t\t\tselector: 'link[rel=stylesheet]',\n\t\t\tattribute: 'href',\n\t\t},\n\t\t{ tagName: 'script', selector: 'script[src]', attribute: 'src' },\n\t];\n\tfor ( const asset of assets ) {\n\t\tconst { tagName, selector, attribute } = asset;\n\t\tconst tags = doc.querySelectorAll<\n\t\t\tHTMLScriptElement | HTMLStyleElement\n\t\t>( selector );\n\n\t\t// Use Promise.all to wait for fetch to complete\n\t\tawait Promise.all(\n\t\t\tArray.from( tags ).map( async ( tag ) => {\n\t\t\t\tconst attributeValue = tag.getAttribute( attribute );\n\t\t\t\tif ( ! headElements.has( attributeValue ) ) {\n\t\t\t\t\ttry {\n\t\t\t\t\t\tconst response = await fetch( attributeValue );\n\t\t\t\t\t\tconst text = await response.text();\n\t\t\t\t\t\theadElements.set( attributeValue, {\n\t\t\t\t\t\t\ttag,\n\t\t\t\t\t\t\ttext,\n\t\t\t\t\t\t} );\n\t\t\t\t\t} catch ( e ) {\n\t\t\t\t\t\t// eslint-disable-next-line no-console\n\t\t\t\t\t\tconsole.error( e );\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tconst headElement = headElements.get( attributeValue );\n\t\t\t\tconst element = doc.createElement( tagName );\n\t\t\t\telement.innerText = headElement.text;\n\t\t\t\tfor ( const attr of headElement.tag.attributes ) {\n\t\t\t\t\telement.setAttribute( attr.name, attr.value );\n\t\t\t\t}\n\t\t\t\theadTags.push( element );\n\t\t\t} )\n\t\t);\n\t}\n\n\treturn [\n\t\tdoc.querySelector( 'title' ),\n\t\t...doc.querySelectorAll( 'style' ),\n\t\t...headTags,\n\t];\n};\n","/**\n * WordPress dependencies\n */\nimport { store, privateApis, getConfig } from '@wordpress/interactivity';\n\n/**\n * Internal dependencies\n */\nimport { fetchHeadAssets, updateHead } from './head';\n\nconst {\n\tdirectivePrefix,\n\tgetRegionRootFragment,\n\tinitialVdom,\n\ttoVdom,\n\trender,\n\tparseServerData,\n\tpopulateServerData,\n\tbatch,\n} = privateApis(\n\t'I acknowledge that using private APIs means my theme or plugin will inevitably break in the next version of WordPress.'\n);\n\ninterface NavigateOptions {\n\tforce?: boolean;\n\thtml?: string;\n\treplace?: boolean;\n\ttimeout?: number;\n\tloadingAnimation?: boolean;\n\tscreenReaderAnnouncement?: boolean;\n}\n\ninterface PrefetchOptions {\n\tforce?: boolean;\n\thtml?: string;\n}\n\ninterface VdomParams {\n\tvdom?: typeof initialVdom;\n}\n\ninterface Page {\n\tregions: Record< string, any >;\n\thead: HTMLHeadElement[];\n\ttitle: string;\n\tinitialData: any;\n}\n\ntype RegionsToVdom = ( dom: Document, params?: VdomParams ) => Promise< Page >;\n\n// Check if the navigation mode is full page or region based.\nconst navigationMode: 'regionBased' | 'fullPage' =\n\tgetConfig( 'core/router' ).navigationMode ?? 'regionBased';\n\n// The cache of visited and prefetched pages, stylesheets and scripts.\nconst pages = new Map< string, Promise< Page | false > >();\nconst headElements = new Map< string, { tag: HTMLElement; text: string } >();\n\n// Helper to remove domain and hash from the URL. We are only interesting in\n// caching the path and the query.\nconst getPagePath = ( url: string ) => {\n\tconst u = new URL( url, window.location.href );\n\treturn u.pathname + u.search;\n};\n\n// Fetch a new page and convert it to a static virtual DOM.\nconst fetchPage = async ( url: string, { html }: { html: string } ) => {\n\ttry {\n\t\tif ( ! html ) {\n\t\t\tconst res = await window.fetch( url );\n\t\t\tif ( res.status !== 200 ) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\thtml = await res.text();\n\t\t}\n\t\tconst dom = new window.DOMParser().parseFromString( html, 'text/html' );\n\t\treturn regionsToVdom( dom );\n\t} catch ( e ) {\n\t\treturn false;\n\t}\n};\n\n// Return an object with VDOM trees of those HTML regions marked with a\n// `router-region` directive.\nconst regionsToVdom: RegionsToVdom = async ( dom, { vdom } = {} ) => {\n\tconst regions = { body: undefined };\n\tlet head: HTMLElement[];\n\tif ( globalThis.IS_GUTENBERG_PLUGIN ) {\n\t\tif ( navigationMode === 'fullPage' ) {\n\t\t\thead = await fetchHeadAssets( dom, headElements );\n\t\t\tregions.body = vdom\n\t\t\t\t? vdom.get( document.body )\n\t\t\t\t: toVdom( dom.body );\n\t\t}\n\t}\n\tif ( navigationMode === 'regionBased' ) {\n\t\tconst attrName = `data-${ directivePrefix }-router-region`;\n\t\tdom.querySelectorAll( `[${ attrName }]` ).forEach( ( region ) => {\n\t\t\tconst id = region.getAttribute( attrName );\n\t\t\tregions[ id ] = vdom?.has( region )\n\t\t\t\t? vdom.get( region )\n\t\t\t\t: toVdom( region );\n\t\t} );\n\t}\n\tconst title = dom.querySelector( 'title' )?.innerText;\n\tconst initialData = parseServerData( dom );\n\treturn { regions, head, title, initialData };\n};\n\n// Render all interactive regions contained in the given page.\nconst renderRegions = ( page: Page ) => {\n\tbatch( () => {\n\t\tif ( globalThis.IS_GUTENBERG_PLUGIN ) {\n\t\t\tif ( navigationMode === 'fullPage' ) {\n\t\t\t\t// Once this code is tested and more mature, the head should be updated for region based navigation as well.\n\t\t\t\tupdateHead( page.head );\n\t\t\t\tconst fragment = getRegionRootFragment( document.body );\n\t\t\t\trender( page.regions.body, fragment );\n\t\t\t}\n\t\t}\n\t\tif ( navigationMode === 'regionBased' ) {\n\t\t\tpopulateServerData( page.initialData );\n\t\t\tconst attrName = `data-${ directivePrefix }-router-region`;\n\t\t\tdocument\n\t\t\t\t.querySelectorAll( `[${ attrName }]` )\n\t\t\t\t.forEach( ( region ) => {\n\t\t\t\t\tconst id = region.getAttribute( attrName );\n\t\t\t\t\tconst fragment = getRegionRootFragment( region );\n\t\t\t\t\trender( page.regions[ id ], fragment );\n\t\t\t\t} );\n\t\t}\n\t\tif ( page.title ) {\n\t\t\tdocument.title = page.title;\n\t\t}\n\t} );\n};\n\n/**\n * Load the given page forcing a full page reload.\n *\n * The function returns a promise that won't resolve, useful to prevent any\n * potential feedback indicating that the navigation has finished while the new\n * page is being loaded.\n *\n * @param href The page href.\n * @return Promise that never resolves.\n */\nconst forcePageReload = ( href: string ) => {\n\twindow.location.assign( href );\n\treturn new Promise( () => {} );\n};\n\n// Listen to the back and forward buttons and restore the page if it's in the\n// cache.\nwindow.addEventListener( 'popstate', async () => {\n\tconst pagePath = getPagePath( window.location.href ); // Remove hash.\n\tconst page = pages.has( pagePath ) && ( await pages.get( pagePath ) );\n\tif ( page ) {\n\t\trenderRegions( page );\n\t\t// Update the URL in the state.\n\t\tstate.url = window.location.href;\n\t} else {\n\t\twindow.location.reload();\n\t}\n} );\n\n// Initialize the router and cache the initial page using the initial vDOM.\n// Once this code is tested and more mature, the head should be updated for\n// region based navigation as well.\nif ( globalThis.IS_GUTENBERG_PLUGIN ) {\n\tif ( navigationMode === 'fullPage' ) {\n\t\t// Cache the scripts. Has to be called before fetching the assets.\n\t\t[].map.call( document.querySelectorAll( 'script[src]' ), ( script ) => {\n\t\t\theadElements.set( script.getAttribute( 'src' ), {\n\t\t\t\ttag: script,\n\t\t\t\ttext: script.textContent,\n\t\t\t} );\n\t\t} );\n\t\tawait fetchHeadAssets( document, headElements );\n\t}\n}\npages.set(\n\tgetPagePath( window.location.href ),\n\tPromise.resolve( regionsToVdom( document, { vdom: initialVdom } ) )\n);\n\n// Check if the link is valid for client-side navigation.\nconst isValidLink = ( ref: HTMLAnchorElement ) =>\n\tref &&\n\tref instanceof window.HTMLAnchorElement &&\n\tref.href &&\n\t( ! ref.target || ref.target === '_self' ) &&\n\tref.origin === window.location.origin &&\n\t! ref.pathname.startsWith( '/wp-admin' ) &&\n\t! ref.pathname.startsWith( '/wp-login.php' ) &&\n\t! ref.getAttribute( 'href' ).startsWith( '#' ) &&\n\t! new URL( ref.href ).searchParams.has( '_wpnonce' );\n\n// Check if the event is valid for client-side navigation.\nconst isValidEvent = ( event: MouseEvent ) =>\n\tevent &&\n\tevent.button === 0 && // Left clicks only.\n\t! event.metaKey && // Open in new tab (Mac).\n\t! event.ctrlKey && // Open in new tab (Windows).\n\t! event.altKey && // Download.\n\t! event.shiftKey &&\n\t! event.defaultPrevented;\n\n// Variable to store the current navigation.\nlet navigatingTo = '';\n\nlet hasLoadedNavigationTextsData = false;\nconst navigationTexts = {\n\tloading: 'Loading page, please wait.',\n\tloaded: 'Page Loaded.',\n};\n\ninterface Store {\n\tstate: {\n\t\turl: string;\n\t\tnavigation: {\n\t\t\thasStarted: boolean;\n\t\t\thasFinished: boolean;\n\t\t};\n\t};\n\tactions: {\n\t\tnavigate: ( href: string, options?: NavigateOptions ) => void;\n\t\tprefetch: ( url: string, options?: PrefetchOptions ) => void;\n\t};\n}\n\nexport const { state, actions } = store< Store >( 'core/router', {\n\tstate: {\n\t\turl: window.location.href,\n\t\tnavigation: {\n\t\t\thasStarted: false,\n\t\t\thasFinished: false,\n\t\t},\n\t},\n\tactions: {\n\t\t/**\n\t\t * Navigates to the specified page.\n\t\t *\n\t\t * This function normalizes the passed href, fetchs the page HTML if\n\t\t * needed, and updates any interactive regions whose contents have\n\t\t * changed. It also creates a new entry in the browser session history.\n\t\t *\n\t\t * @param href The page href.\n\t\t * @param [options] Options object.\n\t\t * @param [options.force] If true, it forces re-fetching the URL.\n\t\t * @param [options.html] HTML string to be used instead of fetching the requested URL.\n\t\t * @param [options.replace] If true, it replaces the current entry in the browser session history.\n\t\t * @param [options.timeout] Time until the navigation is aborted, in milliseconds. Default is 10000.\n\t\t * @param [options.loadingAnimation] Whether an animation should be shown while navigating. Default to `true`.\n\t\t * @param [options.screenReaderAnnouncement] Whether a message for screen readers should be announced while navigating. Default to `true`.\n\t\t *\n\t\t * @return Promise that resolves once the navigation is completed or aborted.\n\t\t */\n\t\t*navigate( href: string, options: NavigateOptions = {} ) {\n\t\t\tconst { clientNavigationDisabled } = getConfig();\n\t\t\tif ( clientNavigationDisabled ) {\n\t\t\t\tyield forcePageReload( href );\n\t\t\t}\n\n\t\t\tconst pagePath = getPagePath( href );\n\t\t\tconst { navigation } = state;\n\t\t\tconst {\n\t\t\t\tloadingAnimation = true,\n\t\t\t\tscreenReaderAnnouncement = true,\n\t\t\t\ttimeout = 10000,\n\t\t\t} = options;\n\n\t\t\tnavigatingTo = href;\n\t\t\tactions.prefetch( pagePath, options );\n\n\t\t\t// Create a promise that resolves when the specified timeout ends.\n\t\t\t// The timeout value is 10 seconds by default.\n\t\t\tconst timeoutPromise = new Promise< void >( ( resolve ) =>\n\t\t\t\tsetTimeout( resolve, timeout )\n\t\t\t);\n\n\t\t\t// Don't update the navigation status immediately, wait 400 ms.\n\t\t\tconst loadingTimeout = setTimeout( () => {\n\t\t\t\tif ( navigatingTo !== href ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tif ( loadingAnimation ) {\n\t\t\t\t\tnavigation.hasStarted = true;\n\t\t\t\t\tnavigation.hasFinished = false;\n\t\t\t\t}\n\t\t\t\tif ( screenReaderAnnouncement ) {\n\t\t\t\t\ta11ySpeak( 'loading' );\n\t\t\t\t}\n\t\t\t}, 400 );\n\n\t\t\tconst page = yield Promise.race( [\n\t\t\t\tpages.get( pagePath ),\n\t\t\t\ttimeoutPromise,\n\t\t\t] );\n\n\t\t\t// Dismiss loading message if it hasn't been added yet.\n\t\t\tclearTimeout( loadingTimeout );\n\n\t\t\t// Once the page is fetched, the destination URL could have changed\n\t\t\t// (e.g., by clicking another link in the meantime). If so, bail\n\t\t\t// out, and let the newer execution to update the HTML.\n\t\t\tif ( navigatingTo !== href ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif (\n\t\t\t\tpage &&\n\t\t\t\t! page.initialData?.config?.[ 'core/router' ]\n\t\t\t\t\t?.clientNavigationDisabled\n\t\t\t) {\n\t\t\t\tyield renderRegions( page );\n\t\t\t\twindow.history[\n\t\t\t\t\toptions.replace ? 'replaceState' : 'pushState'\n\t\t\t\t]( {}, '', href );\n\n\t\t\t\t// Update the URL in the state.\n\t\t\t\tstate.url = href;\n\n\t\t\t\t// Update the navigation status once the the new page rendering\n\t\t\t\t// has been completed.\n\t\t\t\tif ( loadingAnimation ) {\n\t\t\t\t\tnavigation.hasStarted = false;\n\t\t\t\t\tnavigation.hasFinished = true;\n\t\t\t\t}\n\n\t\t\t\tif ( screenReaderAnnouncement ) {\n\t\t\t\t\ta11ySpeak( 'loaded' );\n\t\t\t\t}\n\n\t\t\t\t// Scroll to the anchor if exits in the link.\n\t\t\t\tconst { hash } = new URL( href, window.location.href );\n\t\t\t\tif ( hash ) {\n\t\t\t\t\tdocument.querySelector( hash )?.scrollIntoView();\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tyield forcePageReload( href );\n\t\t\t}\n\t\t},\n\n\t\t/**\n\t\t * Prefetchs the page with the passed URL.\n\t\t *\n\t\t * The function normalizes the URL and stores internally the fetch\n\t\t * promise, to avoid triggering a second fetch for an ongoing request.\n\t\t *\n\t\t * @param url The page URL.\n\t\t * @param [options] Options object.\n\t\t * @param [options.force] Force fetching the URL again.\n\t\t * @param [options.html] HTML string to be used instead of fetching the requested URL.\n\t\t */\n\t\tprefetch( url: string, options: PrefetchOptions = {} ) {\n\t\t\tconst { clientNavigationDisabled } = getConfig();\n\t\t\tif ( clientNavigationDisabled ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst pagePath = getPagePath( url );\n\t\t\tif ( options.force || ! pages.has( pagePath ) ) {\n\t\t\t\tpages.set(\n\t\t\t\t\tpagePath,\n\t\t\t\t\tfetchPage( pagePath, { html: options.html } )\n\t\t\t\t);\n\t\t\t}\n\t\t},\n\t},\n} );\n\n/**\n * Announces a message to screen readers.\n *\n * This is a wrapper around the `@wordpress/a11y` package's `speak` function. It handles importing\n * the package on demand and should be used instead of calling `ally.speak` direacly.\n *\n * @param messageKey The message to be announced by assistive technologies.\n */\nfunction a11ySpeak( messageKey: keyof typeof navigationTexts ) {\n\tif ( ! hasLoadedNavigationTextsData ) {\n\t\thasLoadedNavigationTextsData = true;\n\t\tconst content = document.getElementById(\n\t\t\t'wp-script-module-data-@wordpress/interactivity-router'\n\t\t)?.textContent;\n\t\tif ( content ) {\n\t\t\ttry {\n\t\t\t\tconst parsed = JSON.parse( content );\n\t\t\t\tif ( typeof parsed?.i18n?.loading === 'string' ) {\n\t\t\t\t\tnavigationTexts.loading = parsed.i18n.loading;\n\t\t\t\t}\n\t\t\t\tif ( typeof parsed?.i18n?.loaded === 'string' ) {\n\t\t\t\t\tnavigationTexts.loaded = parsed.i18n.loaded;\n\t\t\t\t}\n\t\t\t} catch {}\n\t\t} else {\n\t\t\t// Fallback to localized strings from Interactivity API state.\n\t\t\t// @todo This block is for Core < 6.7.0. Remove when support is dropped.\n\n\t\t\t// @ts-expect-error\n\t\t\tif ( state.navigation.texts?.loading ) {\n\t\t\t\t// @ts-expect-error\n\t\t\t\tnavigationTexts.loading = state.navigation.texts.loading;\n\t\t\t}\n\t\t\t// @ts-expect-error\n\t\t\tif ( state.navigation.texts?.loaded ) {\n\t\t\t\t// @ts-expect-error\n\t\t\t\tnavigationTexts.loaded = state.navigation.texts.loaded;\n\t\t\t}\n\t\t}\n\t}\n\n\tconst message = navigationTexts[ messageKey ];\n\n\timport( '@wordpress/a11y' ).then(\n\t\t( { speak } ) => speak( message ),\n\t\t// Ignore failures to load the a11y module.\n\t\t() => {}\n\t);\n}\n\n// Add click and prefetch to all links.\nif ( globalThis.IS_GUTENBERG_PLUGIN ) {\n\tif ( navigationMode === 'fullPage' ) {\n\t\t// Navigate on click.\n\t\tdocument.addEventListener(\n\t\t\t'click',\n\t\t\tfunction ( event ) {\n\t\t\t\tconst ref = ( event.target as Element ).closest( 'a' );\n\t\t\t\tif ( isValidLink( ref ) && isValidEvent( event ) ) {\n\t\t\t\t\tevent.preventDefault();\n\t\t\t\t\tactions.navigate( ref.href );\n\t\t\t\t}\n\t\t\t},\n\t\t\ttrue\n\t\t);\n\t\t// Prefetch on hover.\n\t\tdocument.addEventListener(\n\t\t\t'mouseenter',\n\t\t\tfunction ( event ) {\n\t\t\t\tif ( ( event.target as Element )?.nodeName === 'A' ) {\n\t\t\t\t\tconst ref = ( event.target as Element ).closest( 'a' );\n\t\t\t\t\tif ( isValidLink( ref ) && isValidEvent( event ) ) {\n\t\t\t\t\t\tactions.prefetch( ref.href );\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t},\n\t\t\ttrue\n\t\t);\n\t}\n}\n","module.exports = import(\"@wordpress/a11y\");;","var x = y => { var x = {}; __webpack_require__.d(x, y); return x; }\nvar y = x => () => x\nmodule.exports = x({ [\"getConfig\"]: () => __WEBPACK_EXTERNAL_MODULE__wordpress_interactivity_8e89b257__.getConfig, [\"privateApis\"]: () => __WEBPACK_EXTERNAL_MODULE__wordpress_interactivity_8e89b257__.privateApis, [\"store\"]: () => __WEBPACK_EXTERNAL_MODULE__wordpress_interactivity_8e89b257__.store });","// The module cache\nvar __webpack_module_cache__ = {};\n\n// The require function\nfunction __webpack_require__(moduleId) {\n\t// Check if module is in cache\n\tvar cachedModule = __webpack_module_cache__[moduleId];\n\tif (cachedModule !== undefined) {\n\t\treturn cachedModule.exports;\n\t}\n\t// Create a new module (and put it into the cache)\n\tvar module = __webpack_module_cache__[moduleId] = {\n\t\t// no module.id needed\n\t\t// no module.loaded needed\n\t\texports: {}\n\t};\n\n\t// Execute the module function\n\t__webpack_modules__[moduleId](module, module.exports, __webpack_require__);\n\n\t// Return the exports of the module\n\treturn module.exports;\n}\n\n","// define getter functions for harmony exports\n__webpack_require__.d = (exports, definition) => {\n\tfor(var key in definition) {\n\t\tif(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n\t\t\tObject.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n\t\t}\n\t}\n};","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))","// startup\n// Load entry module and return exports\n// This entry module used 'module' so it can't be inlined\nvar __webpack_exports__ = __webpack_require__(126);\n"],"names":["webpackQueues","webpackExports","webpackError","resolveQueue","updateHead","async","getTagId","tag","id","outerHTML","newHeadMap","Map","child","newHead","set","toRemove","document","head","children","nodeName","push","has","delete","toAppend","values","forEach","n","remove","append","fetchHeadAssets","doc","headElements","headTags","assets","tagName","selector","attribute","asset","tags","querySelectorAll","Promise","all","Array","from","map","attributeValue","getAttribute","response","fetch","text","e","console","error","headElement","get","element","createElement","innerText","attr","attributes","setAttribute","name","value","querySelector","directivePrefix","getRegionRootFragment","initialVdom","toVdom","render","parseServerData","populateServerData","batch","privateApis","navigationMode","_getConfig$navigation","getConfig","pages","getPagePath","url","u","URL","window","location","href","pathname","search","fetchPage","html","res","status","dom","DOMParser","parseFromString","regionsToVdom","vdom","regions","body","undefined","attrName","region","title","initialData","renderRegions","page","fragment","forcePageReload","assign","addEventListener","pagePath","state","reload","call","script","textContent","resolve","isValidLink","ref","HTMLAnchorElement","target","origin","startsWith","searchParams","isValidEvent","event","button","metaKey","ctrlKey","altKey","shiftKey","defaultPrevented","navigatingTo","hasLoadedNavigationTextsData","navigationTexts","loading","loaded","actions","store","navigation","hasStarted","hasFinished","navigate","options","clientNavigationDisabled","loadingAnimation","screenReaderAnnouncement","timeout","prefetch","timeoutPromise","setTimeout","loadingTimeout","a11ySpeak","race","clearTimeout","config","history","replace","hash","scrollIntoView","force","messageKey","content","getElementById","parsed","JSON","parse","i18n","texts","message","then","speak","closest","preventDefault","module","exports","import","y","x","__WEBPACK_EXTERNAL_MODULE__wordpress_interactivity_8e89b257__","__webpack_require__","d","__webpack_module_cache__","moduleId","cachedModule","__webpack_modules__","Symbol","queue","fn","r","a","hasAwait","currentDeps","outerResolve","reject","depQueues","Set","promise","rej","deps","dep","obj","ret","wrapDeps","getResult","fnQueue","q","add","err","definition","key","o","Object","defineProperty","enumerable","prop","prototype","hasOwnProperty","__webpack_exports__"],"sourceRoot":""} \ No newline at end of file diff --git a/gutenberg.php b/gutenberg.php index d949cb28..dbfe8828 100644 --- a/gutenberg.php +++ b/gutenberg.php @@ -14,7 +14,7 @@ ### BEGIN AUTO-GENERATED DEFINES define( 'GUTENBERG_VERSION', '19.3.0' ); -define( 'GUTENBERG_GIT_COMMIT', '87b1251e3bc7cca989a928e0f290654332ea2174' ); +define( 'GUTENBERG_GIT_COMMIT', '20ae57d7326f28fdd39ae7d9566919f2c800a6f8' ); ### END AUTO-GENERATED DEFINES defined( 'GUTENBERG_MINIMUM_WP_VERSION' ) or define( 'GUTENBERG_MINIMUM_WP_VERSION', '6.5' );