WordPress/wp-includes/js/dist/plugins.min.js

2 lines
4.0 KiB
JavaScript
Raw Normal View History

/*! This file is auto-generated */
(()=>{"use strict";var e={n:r=>{var n=r&&r.__esModule?()=>r.default:()=>r;return e.d(n,{a:n}),n},d:(r,n)=>{for(var t in n)e.o(n,t)&&!e.o(r,t)&&Object.defineProperty(r,t,{enumerable:!0,get:n[t]})},o:(e,r)=>Object.prototype.hasOwnProperty.call(e,r),r:e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},r={};e.r(r),e.d(r,{PluginArea:()=>y,getPlugin:()=>f,getPlugins:()=>w,registerPlugin:()=>m,unregisterPlugin:()=>v,withPluginContext:()=>a});const n=window.wp.element;const t=window.wp.hooks,o=window.wp.isShallowEqual;var l=e.n(o);const i=window.wp.compose,{Consumer:s,Provider:u}=(0,n.createContext)({name:null,icon:null}),a=e=>(0,i.createHigherOrderComponent)((r=>t=>(0,n.createElement)(s,null,(o=>(0,n.createElement)(r,{...t,...e(o,t)})))),"withPluginContext");class c extends n.Component{constructor(e){super(e),this.state={hasError:!1}}static getDerivedStateFromError(){return{hasError:!0}}componentDidCatch(e){const{name:r,onError:n}=this.props;n&&n(r,e)}render(){return this.state.hasError?null:this.props.children}}const p=window.wp.primitives,g=(0,n.createElement)(p.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},(0,n.createElement)(p.Path,{d:"M10.5 4v4h3V4H15v4h1.5a1 1 0 011 1v4l-3 4v2a1 1 0 01-1 1h-3a1 1 0 01-1-1v-2l-3-4V9a1 1 0 011-1H9V4h1.5zm.5 12.5v2h2v-2l3-4v-3H8v3l3 4z"})),d={};function m(e,r){if("object"!=typeof r)return console.error("No settings object provided!"),null;if("string"!=typeof e)return console.error("Plugin name must be string."),null;if(!/^[a-z][a-z0-9-]*$/.test(e))return console.error('Plugin name must include only lowercase alphanumeric characters or dashes, and start with a letter. Example: "my-plugin".'),null;d[e]&&console.error(`Plugin "${e}" is already registered.`),r=(0,t.applyFilters)("plugins.registerPlugin",r,e);const{render:n,scope:o}=r;if("function"!=typeof n)return console.error('The "render" property must be specified and must be a valid function.'),null;if(o){if("string"!=typeof o)return console.error("Plugin scope must be string."),null;if(!/^[a-z][a-z0-9-]*$/.test(o))return console.error('Plugin scope must include only lowercase alphanumeric characters or dashes, and start with a letter. Example: "my-page".'),null}return d[e]={name:e,icon:g,...r},(0,t.doAction)("plugins.pluginRegistered",r,e),r}function v(e){if(!d[e])return void console.error('Plugin "'+e+'" is not registered.');const r=d[e];return delete d[e],(0,t.doAction)("plugins.pluginUnregistered",r,e),r}function f(e){return d[e]}function w(e){return Object.values(d).filter((r=>r.scope===e))}const h=function(e,r){var n,t,o=0;function l(){var l,i,s=n,u=arguments.length;e:for(;s;){if(s.args.length===arguments.length){for(i=0;i<u;i++)if(s.args[i]!==arguments[i]){s=s.next;continue e}return s!==n&&(s===t&&(t=s.prev),s.prev.next=s.next,s.next&&(s.next.prev=s.prev),s.next=n,s.prev=null,n.prev=s,n=s),s.val}s=s.next}for(l=new Array(u),i=0;i<u;i++)l[i]=arguments[i];return s={args:l,val:e.apply(null,l)},n?(n.prev=s,s.next=n):t=s,o===r.maxSize?(t=t.prev).next=null:o++,n=s,s.val}return r=r||{},l.clear=function(){n=null,t=null,o=0},l}(((e,r)=>({icon:e,name:r})));const y=function({scope:e,onError:r}){const o=(0,n.useMemo)((()=>{let r=[];return{subscribe:e=>((0,t.addAction)("plugins.pluginRegistered","core/plugins/plugin-area/plugins-registered",e),(0,t.addAction)("plugins.pluginUnregistered","core/plugins/plugin-area/plugins-unregistered",e),()=>{(0,t.removeAction)("plugins.pluginRegistered","core/plugins/plugin-area/plugins-registered"),(0,t.removeAction)("plugins.pluginUnregistered","core/plugins/plugin-area/plugins-unregistered")}),getValue(){const n=w(e);return l()(r,n)||(r=n),r}}}),[e]),i=(0,n.useSyncExternalStore)(o.subscribe,o.getValue);return(0,n.createElement)("div",{style:{display:"none"}},i.map((({icon:e,name:t,render:o})=>(0,n.createElement)(u,{key:t,value:h(e,t)},(0,n.createElement)(c,{name:t,onError:r},(0,n.createElement)(o,null))))))};(window.wp=window.wp||{}).plugins=r})();