WordPress/wp-includes/js/dist/server-side-render.min.js

2 lines
4.7 KiB
JavaScript

/*! This file is auto-generated */
this.wp=this.wp||{},this.wp.serverSideRender=function(e){var t={};function r(n){if(t[n])return t[n].exports;var o=t[n]={i:n,l:!1,exports:{}};return e[n].call(o.exports,o,o.exports,r),o.l=!0,o.exports}return r.m=e,r.c=t,r.d=function(e,t,n){r.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.t=function(e,t){if(1&t&&(e=r(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)r.d(n,o,function(t){return e[t]}.bind(null,o));return n},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="",r(r.s="4dqW")}({"1ZqX":function(e,t){e.exports=window.wp.data},"4dqW":function(e,t,r){"use strict";r.r(t);var n=r("wx14"),o=r("GRId"),c=r("1ZqX"),u=r("NMb1"),l=r.n(u),s=r("YLtl"),i=r("K9lf"),a=r("l3Sj"),d=r("ywyh"),p=r.n(d),f=r("Mmq9"),b=r("tI+e"),w=r("HSyU");function O(e){let{className:t}=e;return Object(o.createElement)(b.Placeholder,{className:t},Object(a.__)("Block rendered as empty."))}function j(e){let{response:t,className:r}=e;const n=Object(a.sprintf)(Object(a.__)("Error loading block: %s"),t.errorMsg);return Object(o.createElement)(b.Placeholder,{className:r},n)}function m(e){let{children:t,showLoader:r}=e;return Object(o.createElement)("div",{style:{position:"relative"}},r&&Object(o.createElement)("div",{style:{position:"absolute",top:"50%",left:"50%",marginTop:"-9px",marginLeft:"-9px"}},Object(o.createElement)(b.Spinner,null)),Object(o.createElement)("div",{style:{opacity:r?"0.3":1}},t))}function y(e){const{attributes:t,block:r,className:c,httpMethod:u="GET",urlQueryArgs:l,EmptyResponsePlaceholder:a=O,ErrorResponsePlaceholder:d=j,LoadingResponsePlaceholder:b=m}=e,y=Object(o.useRef)(!0),[h,v]=Object(o.useState)(!1),S=Object(o.useRef)(),[g,E]=Object(o.useState)(null),x=Object(i.usePrevious)(e),[P,M]=Object(o.useState)(!1);function R(){if(!y.current)return;M(!0);const e=t&&Object(w.__experimentalSanitizeBlockAttributes)(r,t),n="POST"===u,o=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return Object(f.addQueryArgs)("/wp/v2/block-renderer/"+e,{context:"edit",...null!==t?{attributes:t}:{},...r})}(r,n?null:null!=e?e:null,l),c=n?{attributes:null!=e?e:null}:null,s=S.current=p()({path:o,data:c,method:n?"POST":"GET"}).then(e=>{y.current&&s===S.current&&e&&E(e.rendered)}).catch(e=>{y.current&&s===S.current&&E({error:!0,errorMsg:e.message})}).finally(()=>{y.current&&s===S.current&&M(!1)});return s}const _=Object(i.useDebounce)(R,500);Object(o.useEffect)(()=>()=>{y.current=!1},[]),Object(o.useEffect)(()=>{void 0===x?R():Object(s.isEqual)(x,e)||_()}),Object(o.useEffect)(()=>{if(!P)return;const e=setTimeout(()=>{v(!0)},1e3);return()=>clearTimeout(e)},[P]);const T=!!g,N=""===g,L=null==g?void 0:g.error;return N||!T?Object(o.createElement)(a,e):L?Object(o.createElement)(d,Object(n.a)({response:g},e)):P?Object(o.createElement)(b,Object(n.a)({},e,{showLoader:h}),T&&Object(o.createElement)(o.RawHTML,{className:c},g)):Object(o.createElement)(o.RawHTML,{className:c},g)}const h={},v=Object(c.withSelect)(e=>{const t=e("core/editor");if(t){const e=t.getCurrentPostId();if(e&&"number"==typeof e)return{currentPostId:e}}return h})(e=>{let{urlQueryArgs:t=h,currentPostId:r,...c}=e;const u=Object(o.useMemo)(()=>r?{post_id:r,...t}:t,[r,t]);return Object(o.createElement)(y,Object(n.a)({urlQueryArgs:u},c))});window&&window.wp&&window.wp.components&&(window.wp.components.ServerSideRender=Object(o.forwardRef)((e,t)=>(l()("wp.components.ServerSideRender",{since:"5.3",alternative:"wp.serverSideRender"}),Object(o.createElement)(v,Object(n.a)({},e,{ref:t})))));t.default=v},GRId:function(e,t){e.exports=window.wp.element},HSyU:function(e,t){e.exports=window.wp.blocks},K9lf:function(e,t){e.exports=window.wp.compose},Mmq9:function(e,t){e.exports=window.wp.url},NMb1:function(e,t){e.exports=window.wp.deprecated},YLtl:function(e,t){e.exports=window.lodash},l3Sj:function(e,t){e.exports=window.wp.i18n},"tI+e":function(e,t){e.exports=window.wp.components},wx14:function(e,t,r){"use strict";function n(){return(n=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e}).apply(this,arguments)}r.d(t,"a",(function(){return n}))},ywyh:function(e,t){e.exports=window.wp.apiFetch}}).default;