diff --git a/content.js b/content.js index bc82059..22a1ab7 100644 --- a/content.js +++ b/content.js @@ -242,6 +242,19 @@ return true; } + if (msg.type === 'RESOLVE_TEMPLATE_EDIT_URL') { + // Template-backed views (blog index, archives) on block themes resolve + // to a site-editor deep link. Needs an authenticated REST round-trip + // (/themes + /templates are private), so the popup passes the nonce it + // already resolves for the site-info/user endpoints. + const nonce = msg.nonce || null; + globalThis.WPRest + .resolveTemplateEditUrlAsync({ ctx: detection.context, origin: location.origin, nonce }) + .then((res) => sendResponse(res || { url: null, isBlockTheme: null })) + .catch(() => sendResponse({ url: null, isBlockTheme: null })); + return true; + } + if (msg.type === 'GET_SITE_INFO') { // Runs from the page context, so cookies flow automatically. The popup // pre-reads window.wpApiSettings.nonce via chrome.scripting (MAIN world, diff --git a/dist/popup.js b/dist/popup.js index 686abc0..ff7fb3a 100644 --- a/dist/popup.js +++ b/dist/popup.js @@ -1 +1 @@ -(()=>{var e,t,n={20:(e,t,n)=>{"use strict";var r=n(540),o=Symbol.for("react.element"),a=Symbol.for("react.fragment"),i=Object.prototype.hasOwnProperty,l=r.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,s={key:!0,ref:!0,__self:!0,__source:!0};function c(e,t,n){var r,a={},c=null,u=null;for(r in void 0!==n&&(c=""+n),void 0!==t.key&&(c=""+t.key),void 0!==t.ref&&(u=t.ref),t)i.call(t,r)&&!s.hasOwnProperty(r)&&(a[r]=t[r]);if(e&&e.defaultProps)for(r in t=e.defaultProps)void 0===a[r]&&(a[r]=t[r]);return{$$typeof:o,type:e,key:c,ref:u,props:a,_owner:l.current}}t.Fragment=a,t.jsx=c,t.jsxs=c},162:(e,t,n)=>{"use strict";var r=n(540),o=n(888),a="function"==typeof Object.is?Object.is:function(e,t){return e===t&&(0!==e||1/e==1/t)||e!=e&&t!=t},i=o.useSyncExternalStore,l=r.useRef,s=r.useEffect,c=r.useMemo,u=r.useDebugValue;t.useSyncExternalStoreWithSelector=function(e,t,n,r,o){var d=l(null);if(null===d.current){var f={hasValue:!1,value:null};d.current=f}else f=d.current;d=c(function(){function e(e){if(!s){if(s=!0,i=e,e=r(e),void 0!==o&&f.hasValue){var t=f.value;if(o(t,e))return l=t}return l=e}if(t=l,a(i,e))return t;var n=r(e);return void 0!==o&&o(t,n)?(i=e,t):(i=e,l=n)}var i,l,s=!1,c=void 0===n?null:n;return[function(){return e(t())},null===c?void 0:function(){return e(c())}]},[t,n,r,o]);var p=i(e,d[0],d[1]);return s(function(){f.hasValue=!0,f.value=p},[p]),u(p),p}},242:(e,t,n)=>{"use strict";e.exports=n(162)},287:(e,t)=>{"use strict";var n=Symbol.for("react.element"),r=Symbol.for("react.portal"),o=Symbol.for("react.fragment"),a=Symbol.for("react.strict_mode"),i=Symbol.for("react.profiler"),l=Symbol.for("react.provider"),s=Symbol.for("react.context"),c=Symbol.for("react.forward_ref"),u=Symbol.for("react.suspense"),d=Symbol.for("react.memo"),f=Symbol.for("react.lazy"),p=Symbol.iterator,h={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},m=Object.assign,g={};function b(e,t,n){this.props=e,this.context=t,this.refs=g,this.updater=n||h}function v(){}function y(e,t,n){this.props=e,this.context=t,this.refs=g,this.updater=n||h}b.prototype.isReactComponent={},b.prototype.setState=function(e,t){if("object"!=typeof e&&"function"!=typeof e&&null!=e)throw Error("setState(...): takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,e,t,"setState")},b.prototype.forceUpdate=function(e){this.updater.enqueueForceUpdate(this,e,"forceUpdate")},v.prototype=b.prototype;var w=y.prototype=new v;w.constructor=y,m(w,b.prototype),w.isPureReactComponent=!0;var x=Array.isArray,k=Object.prototype.hasOwnProperty,_={current:null},S={key:!0,ref:!0,__self:!0,__source:!0};function E(e,t,r){var o,a={},i=null,l=null;if(null!=t)for(o in void 0!==t.ref&&(l=t.ref),void 0!==t.key&&(i=""+t.key),t)k.call(t,o)&&!S.hasOwnProperty(o)&&(a[o]=t[o]);var s=arguments.length-2;if(1===s)a.children=r;else if(1{!function(){"use strict";const t=new Set(["wp/v2","wp/v2/fields","wp-site-health/v1","oembed/1.0","wp-block-editor/v1","akismet/v1"]);function n(e){if("string"!=typeof e||!e)return null;try{const t=new URL(e).protocol;if("http:"===t||"https:"===t)return e}catch(e){}return null}const r={mergePlugins:function(e,r,o){const a=new Map;for(const t of e)a.set(t,{slug:t,name:null,version:null,active:null,pluginUri:null});for(const e of o||[]){if(t.has(e))continue;const n=e.split("/")[0];n&&"wp"!==n&&(a.has(n)||a.set(n,{slug:n,name:null,version:null,active:null,pluginUri:null}))}for(const e of r||[]){const t=(e.plugin||"").split("/")[0];if(!t)continue;const r={slug:t,name:e.name||null,version:e.version||null,active:"active"===e.status,pluginUri:n(e.plugin_uri)};a.set(t,r)}return Array.from(a.values()).filter(e=>!1!==e.active).sort((e,t)=>e.slug.localeCompare(t.slug))},mergeTheme:function(e,t){return e||t?t?{slug:t.stylesheet||e,name:t.name?.rendered||t.name||e,version:t.version||null,author:t.author?.rendered||t.author||null}:{slug:e,name:e,version:null,author:null}:null},stripTags:function(e){return"string"!=typeof e?"":e.replace(/<[^>]*>/g,"").trim()}};globalThis.WPSiteInfo=r,e.exports&&(e.exports=r)}()},338:(e,t,n)=>{"use strict";var r=n(961);t.H=r.createRoot,r.hydrateRoot},463:(e,t)=>{"use strict";function n(e,t){var n=e.length;e.push(t);e:for(;0>>1,o=e[r];if(!(0>>1;ra(s,n))ca(u,s)?(e[r]=u,e[c]=n,r=c):(e[r]=s,e[l]=n,r=l);else{if(!(ca(u,n)))break e;e[r]=u,e[c]=n,r=c}}}return t}function a(e,t){var n=e.sortIndex-t.sortIndex;return 0!==n?n:e.id-t.id}if("object"==typeof performance&&"function"==typeof performance.now){var i=performance;t.unstable_now=function(){return i.now()}}else{var l=Date,s=l.now();t.unstable_now=function(){return l.now()-s}}var c=[],u=[],d=1,f=null,p=3,h=!1,m=!1,g=!1,b="function"==typeof setTimeout?setTimeout:null,v="function"==typeof clearTimeout?clearTimeout:null,y="undefined"!=typeof setImmediate?setImmediate:null;function w(e){for(var t=r(u);null!==t;){if(null===t.callback)o(u);else{if(!(t.startTime<=e))break;o(u),t.sortIndex=t.expirationTime,n(c,t)}t=r(u)}}function x(e){if(g=!1,w(e),!m)if(null!==r(c))m=!0,j(k);else{var t=r(u);null!==t&&z(x,t.startTime-e)}}function k(e,n){m=!1,g&&(g=!1,v(C),C=-1),h=!0;var a=p;try{for(w(n),f=r(c);null!==f&&(!(f.expirationTime>n)||e&&!T());){var i=f.callback;if("function"==typeof i){f.callback=null,p=f.priorityLevel;var l=i(f.expirationTime<=n);n=t.unstable_now(),"function"==typeof l?f.callback=l:f===r(c)&&o(c),w(n)}else o(c);f=r(c)}if(null!==f)var s=!0;else{var d=r(u);null!==d&&z(x,d.startTime-n),s=!1}return s}finally{f=null,p=a,h=!1}}"undefined"!=typeof navigator&&void 0!==navigator.scheduling&&void 0!==navigator.scheduling.isInputPending&&navigator.scheduling.isInputPending.bind(navigator.scheduling);var _,S=!1,E=null,C=-1,R=5,M=-1;function T(){return!(t.unstable_now()-Me||125i?(e.sortIndex=a,n(u,e),null===r(c)&&e===r(u)&&(g?(v(C),C=-1):g=!0,z(x,a-i))):(e.sortIndex=l,n(c,e),m||h||(m=!0,j(k))),e},t.unstable_shouldYield=T,t.unstable_wrapCallback=function(e){var t=p;return function(){var n=p;p=t;try{return e.apply(this,arguments)}finally{p=n}}}},493:(e,t,n)=>{"use strict";var r=n(540),o="function"==typeof Object.is?Object.is:function(e,t){return e===t&&(0!==e||1/e==1/t)||e!=e&&t!=t},a=r.useState,i=r.useEffect,l=r.useLayoutEffect,s=r.useDebugValue;function c(e){var t=e.getSnapshot;e=e.value;try{var n=t();return!o(e,n)}catch(e){return!0}}var u="undefined"==typeof window||void 0===window.document||void 0===window.document.createElement?function(e,t){return t()}:function(e,t){var n=t(),r=a({inst:{value:n,getSnapshot:t}}),o=r[0].inst,u=r[1];return l(function(){o.value=n,o.getSnapshot=t,c(o)&&u({inst:o})},[e,n,t]),i(function(){return c(o)&&u({inst:o}),e(function(){c(o)&&u({inst:o})})},[e]),s(n),n};t.useSyncExternalStore=void 0!==r.useSyncExternalStore?r.useSyncExternalStore:u},540:(e,t,n)=>{"use strict";e.exports=n(287)},551:(e,t,n)=>{"use strict";var r=n(540),o=n(982);function a(e){for(var t="https://reactjs.org/docs/error-decoder.html?invariant="+e,n=1;n