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

2 lines
20 KiB
JavaScript
Raw Normal View History

/*! This file is auto-generated */
(()=>{"use strict";var e={n:t=>{var l=t&&t.__esModule?()=>t.default:()=>t;return e.d(l,{a:l}),l},d:(t,l)=>{for(var o in l)e.o(l,o)&&!e.o(t,o)&&Object.defineProperty(t,o,{enumerable:!0,get:l[o]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r: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:()=>G});var l={};e.r(l),e.d(l,{getDownloadableBlocks:()=>h,getErrorNoticeForBlock:()=>f,getErrorNotices:()=>y,getInstalledBlockTypes:()=>m,getNewBlockTypes:()=>g,getUnusedBlockTypes:()=>w,isInstalling:()=>_,isRequestingDownloadableBlocks:()=>k});var o={};e.r(o),e.d(o,{addInstalledBlockType:()=>C,clearErrorNotice:()=>P,fetchDownloadableBlocks:()=>T,installBlockType:()=>S,receiveDownloadableBlocks:()=>L,removeInstalledBlockType:()=>A,setErrorNotice:()=>D,setIsInstalling:()=>R,uninstallBlockType:()=>O});var s={};e.r(s),e.d(s,{getDownloadableBlocks:()=>Y});const n=window.wp.plugins,r=window.wp.hooks,i=window.wp.blocks,a=window.wp.data,c=window.wp.element,d=window.wp.editor,u=(0,a.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]:l,...o}=e;return o}return e}}),p=window.wp.blockEditor;function b(e,t=[]){if(!t.length)return!1;if(t.some((({name:t})=>t===e.name)))return!0;for(let l=0;l<t.length;l++)if(b(e,t[l].innerBlocks))return!0;return!1}function k(e,t){var l;return null!==(l=e.downloadableBlocks[t]?.isRequesting)&&void 0!==l&&l}function h(e,t){var l;return null!==(l=e.downloadableBlocks[t]?.results)&&void 0!==l?l:[]}function m(e){return e.blockManagement.installedBlockTypes}const g=(0,a.createRegistrySelector)((e=>t=>{const l=e(p.store).getBlocks();return m(t).filter((e=>b(e,l)))})),w=(0,a.createRegistrySelector)((e=>t=>{const l=e(p.store).getBlocks();return m(t).filter((e=>!b(e,l)))}));function _(e,t){return e.blockManagement.isInstalling[t]||!1}function y(e){return e.errorNotices}function f(e,t){return e.errorNotices[t]}const v=window.wp.i18n,x=window.wp.apiFetch;var j=e.n(x);const B=window.wp.notices,E=window.wp.url,N=e=>new Promise(((t,l)=>{const o=document.createElement(e.nodeName);["id","rel","src","href","type"].forEach((t=>{e[t]&&(o[t]=e[t])})),e.innerHTML&&o.appendChild(document.createTextNode(e.innerHTML)),o.onload=()=>t(!0),o.onerror=()=>l(new Error("Error loading asset.")),document.body.appendChild(o),("link"===o.nodeName.toLowerCase()||"script"===o.nodeName.toLowerCase()&&!o.src)&&t()}));function I(e){if(!e)return!1;const t=e.links["wp:plugin"]||e.links.self;return!(!t||!t.length)&&t[0].href}function T(e){return{type:"FETCH_DOWNLOADABLE_BLOCKS",filterValue:e}}function L(e,t){return{type:"RECEIVE_DOWNLOADABLE_BLOCKS",downloadableBlocks:e,filterValue:t}}const S=e=>async({registry:t,dispatch:l})=>{const{id:o,name:s}=e;let n=!1;l.clearErrorNotice(o);try{l.setIsInstalling(o,!0);const r=I(e);let a={};if(r)await j()({method:"PUT",url:r,data:{status:"active"}});else{a=(await j()({method:"POST",path:"wp/v2/plugins",data:{slug:o,status:"active"}}))._links}l.addInstalledBlockType({...e,links:{...e.links,...a}});const c=["api_version","title","category","parent","icon","description","keywords","attributes","provides_context","uses_context","supports","styles","example","variations"];await j()({path:(0,E.addQueryArgs)(`