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

2 lines
4.2 KiB
JavaScript

/*! This file is auto-generated */
!function(){"use strict";var e={n:function(n){var r=n&&n.__esModule?function(){return n.default}:function(){return n};return e.d(r,{a:r}),r},d:function(n,r){for(var t in r)e.o(r,t)&&!e.o(n,t)&&Object.defineProperty(n,t,{enumerable:!0,get:r[t]})},o:function(e,n){return Object.prototype.hasOwnProperty.call(e,n)},r:function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},n={};e.r(n),e.d(n,{PluginArea:function(){return y},getPlugin:function(){return v},getPlugins:function(){return w},registerPlugin:function(){return f},unregisterPlugin:function(){return m},withPluginContext:function(){return a}});var r=window.wp.element;var t=window.wp.hooks,o=window.wp.isShallowEqual,i=e.n(o),l=window.wp.compose;const{Consumer:u,Provider:s}=(0,r.createContext)({name:null,icon:null}),a=e=>(0,l.createHigherOrderComponent)((n=>t=>(0,r.createElement)(u,null,(o=>(0,r.createElement)(n,{...t,...e(o,t)})))),"withPluginContext");class c extends r.Component{constructor(e){super(e),this.state={hasError:!1}}static getDerivedStateFromError(){return{hasError:!0}}componentDidCatch(e){const{name:n,onError:r}=this.props;r&&r(n,e)}render(){return this.state.hasError?null:this.props.children}}var p=window.wp.primitives;var g=(0,r.createElement)(p.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},(0,r.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"}));const d={};function f(e,n){if("object"!=typeof n)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.`),n=(0,t.applyFilters)("plugins.registerPlugin",n,e);const{render:r,scope:o}=n;if("function"!=typeof r)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,...n},(0,t.doAction)("plugins.pluginRegistered",n,e),n}function m(e){if(!d[e])return void console.error('Plugin "'+e+'" is not registered.');const n=d[e];return delete d[e],(0,t.doAction)("plugins.pluginUnregistered",n,e),n}function v(e){return d[e]}function w(e){return Object.values(d).filter((n=>n.scope===e))}const h=function(e,n){var r,t,o=0;function i(){var i,l,u=r,s=arguments.length;e:for(;u;){if(u.args.length===arguments.length){for(l=0;l<s;l++)if(u.args[l]!==arguments[l]){u=u.next;continue e}return u!==r&&(u===t&&(t=u.prev),u.prev.next=u.next,u.next&&(u.next.prev=u.prev),u.next=r,u.prev=null,r.prev=u,r=u),u.val}u=u.next}for(i=new Array(s),l=0;l<s;l++)i[l]=arguments[l];return u={args:i,val:e.apply(null,i)},r?(r.prev=u,u.next=r):t=u,o===n.maxSize?(t=t.prev).next=null:o++,r=u,u.val}return n=n||{},i.clear=function(){r=null,t=null,o=0},i}(((e,n)=>({icon:e,name:n})));var y=function({scope:e,onError:n}){const o=(0,r.useMemo)((()=>{let n=[];return{subscribe(e){return(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 r=w(e);return i()(n,r)||(n=r),n}}}),[e]),l=(0,r.useSyncExternalStore)(o.subscribe,o.getValue);return(0,r.createElement)("div",{style:{display:"none"}},l.map((({icon:e,name:t,render:o})=>(0,r.createElement)(s,{key:t,value:h(e,t)},(0,r.createElement)(c,{name:t,onError:n},(0,r.createElement)(o,null))))))};(window.wp=window.wp||{}).plugins=n}();