WordPress/wp-includes/js/dist/block-directory.min.js

2 lines
21 KiB
JavaScript
Raw Normal View History

/*! This file is auto-generated */
!function(){"use strict";var e={n:function(t){var n=t&&t.__esModule?function(){return t.default}:function(){return t};return e.d(n,{a:n}),n},d:function(t,n){for(var l in n)e.o(n,l)&&!e.o(t,l)&&Object.defineProperty(t,l,{enumerable:!0,get:n[l]})},o:function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r:function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},t={};e.r(t),e.d(t,{store:function(){return G}});var n={};e.r(n),e.d(n,{getDownloadableBlocks:function(){return k},getErrorNoticeForBlock:function(){return y},getErrorNotices:function(){return E},getInstalledBlockTypes:function(){return g},getNewBlockTypes:function(){return _},getUnusedBlockTypes:function(){return f},isInstalling:function(){return w},isRequestingDownloadableBlocks:function(){return b}});var l={};e.r(l),e.d(l,{addInstalledBlockType:function(){return D},clearErrorNotice:function(){return x},fetchDownloadableBlocks:function(){return S},installBlockType:function(){return O},receiveDownloadableBlocks:function(){return C},removeInstalledBlockType:function(){return R},setErrorNotice:function(){return M},setIsInstalling:function(){return P},uninstallBlockType:function(){return A}});var r={};e.r(r),e.d(r,{getDownloadableBlocks:function(){return Y}});var o=window.wp.element,a=window.wp.plugins,s=window.wp.hooks,c=window.wp.blocks,i=window.wp.data,d=window.wp.editor;var u=(0,i.combineReducers)({downloadableBlocks:(e={},t)=>{switch(t.type){case"FETCH_DOWNLOADABLE_BLOCKS":return{...e,[t.filterValue]:{isRequesting:!0}};case"RECEIVE_DOWNLOADABLE_BLOCKS":return{...e,[t.filterValue]:{results:t.downloadableBlocks,isRequesting:!1}}}return e},blockManagement:(e={installedBlockTypes:[],isInstalling:{}},t)=>{switch(t.type){case"ADD_INSTALLED_BLOCK_TYPE":return{...e,installedBlockTypes:[...e.installedBlockTypes,t.item]};case"REMOVE_INSTALLED_BLOCK_TYPE":return{...e,installedBlockTypes:e.installedBlockTypes.filter((e=>e.name!==t.item.name))};case"SET_INSTALLING_BLOCK":return{...e,isInstalling:{...e.isInstalling,[t.blockId]:t.isInstalling}}}return e},errorNotices:(e={},t)=>{switch(t.type){case"SET_ERROR_NOTICE":return{...e,[t.blockId]:{message:t.message,isFatal:t.isFatal}};case"CLEAR_ERROR_NOTICE":const{[t.blockId]:n,...l}=e;return l}return e}}),m=window.wp.blockEditor;function p(e,t=[]){if(!t.length)return!1;if(t.some((({name:t})=>t===e.name)))return!0;for(let n=0;n<t.length;n++)if(p(e,t[n].innerBlocks))return!0;return!1}function b(e,t){var n;return null!==(n=e.downloadableBlocks[t]?.isRequesting)&&void 0!==n&&n}function k(e,t){var n;return null!==(n=e.downloadableBlocks[t]?.results)&&void 0!==n?n:[]}function g(e){return e.blockManagement.installedBlockTypes}const _=(0,i.createRegistrySelector)((e=>t=>{const n=e(m.store).getBlocks();return g(t).filter((e=>p(e,n)))})),f=(0,i.createRegistrySelector)((e=>t=>{const n=e(m.store).getBlocks();return g(t).filter((e=>!p(e,n)))}));function w(e,t){return e.blockManagement.isInstalling[t]||!1}function E(e){return e.errorNotices}function y(e,t){return e.errorNotices[t]}var h=window.wp.i18n,v=window.wp.apiFetch,B=e.n(v),I=window.wp.notices,N=window.wp.url;const T=e=>new Promise(((t,n)=>{const l=document.createElement(e.nodeName);["id","rel","src","href","type"].forEach((t=>{e[t]&&(l[t]=e[t])})),e.innerHTML&&l.appendChild(document.createTextNode(e.innerHTML)),l.onload=()=>t(!0),l.onerror=()=>n(new Error("Error loading asset.")),document.body.appendChild(l),("link"===l.nodeName.toLowerCase()||"script"===l.nodeName.toLowerCase()&&!l.src)&&t()}));function L(e){if(!e)return!1;const t=e.links["wp:plugin"]||e.links.self;return!(!t||!t.length)&&t[0].href}function S(e){return{type:"FETCH_DOWNLOADABLE_BLOCKS",filterValue:e}}function C(e,t){return{type:"RECEIVE_DOWNLOADABLE_BLOCKS",downloadableBlocks:e,filterValue:t}}const O=e=>async({registry:t,dispatch:n})=>{const{id:l,name:r}=e;let o=!1;n.clearErrorNotice(l);try{n.setIsInstalling(l,!0);const a=L(e);let s={};if(a)await B()({method:"PUT",url:a,data:{status:"active"}});else{s