[ Index ]

PHP Cross Reference of WordPress

title

Body

[close]

/wp-includes/js/dist/ -> plugins.js (source)

   1  this["wp"] = this["wp"] || {}; this["wp"]["plugins"] =
   2  /******/ (function(modules) { // webpackBootstrap
   3  /******/     // The module cache
   4  /******/     var installedModules = {};
   5  /******/
   6  /******/     // The require function
   7  /******/ 	function __webpack_require__(moduleId) {
   8  /******/
   9  /******/         // Check if module is in cache
  10  /******/         if(installedModules[moduleId]) {
  11  /******/             return installedModules[moduleId].exports;
  12  /******/         }
  13  /******/         // Create a new module (and put it into the cache)
  14  /******/         var module = installedModules[moduleId] = {
  15  /******/             i: moduleId,
  16  /******/             l: false,
  17  /******/             exports: {}
  18  /******/         };
  19  /******/
  20  /******/         // Execute the module function
  21  /******/         modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
  22  /******/
  23  /******/         // Flag the module as loaded
  24  /******/         module.l = true;
  25  /******/
  26  /******/         // Return the exports of the module
  27  /******/         return module.exports;
  28  /******/     }
  29  /******/
  30  /******/
  31  /******/     // expose the modules object (__webpack_modules__)
  32  /******/     __webpack_require__.m = modules;
  33  /******/
  34  /******/     // expose the module cache
  35  /******/     __webpack_require__.c = installedModules;
  36  /******/
  37  /******/     // define getter function for harmony exports
  38  /******/     __webpack_require__.d = function(exports, name, getter) {
  39  /******/         if(!__webpack_require__.o(exports, name)) {
  40  /******/             Object.defineProperty(exports, name, { enumerable: true, get: getter });
  41  /******/         }
  42  /******/     };
  43  /******/
  44  /******/     // define __esModule on exports
  45  /******/     __webpack_require__.r = function(exports) {
  46  /******/         if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
  47  /******/             Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
  48  /******/         }
  49  /******/         Object.defineProperty(exports, '__esModule', { value: true });
  50  /******/     };
  51  /******/
  52  /******/     // create a fake namespace object
  53  /******/     // mode & 1: value is a module id, require it
  54  /******/     // mode & 2: merge all properties of value into the ns
  55  /******/     // mode & 4: return value when already ns object
  56  /******/     // mode & 8|1: behave like require
  57  /******/     __webpack_require__.t = function(value, mode) {
  58  /******/         if(mode & 1) value = __webpack_require__(value);
  59  /******/         if(mode & 8) return value;
  60  /******/         if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
  61  /******/         var ns = Object.create(null);
  62  /******/         __webpack_require__.r(ns);
  63  /******/         Object.defineProperty(ns, 'default', { enumerable: true, value: value });
  64  /******/         if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
  65  /******/         return ns;
  66  /******/     };
  67  /******/
  68  /******/     // getDefaultExport function for compatibility with non-harmony modules
  69  /******/     __webpack_require__.n = function(module) {
  70  /******/         var getter = module && module.__esModule ?
  71  /******/ 			function getDefault() { return module['default']; } :
  72  /******/ 			function getModuleExports() { return module; };
  73  /******/         __webpack_require__.d(getter, 'a', getter);
  74  /******/         return getter;
  75  /******/     };
  76  /******/
  77  /******/     // Object.prototype.hasOwnProperty.call
  78  /******/     __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
  79  /******/
  80  /******/     // __webpack_public_path__
  81  /******/     __webpack_require__.p = "";
  82  /******/
  83  /******/
  84  /******/     // Load entry module and return exports
  85  /******/     return __webpack_require__(__webpack_require__.s = 474);
  86  /******/ })
  87  /************************************************************************/
  88  /******/ ({
  89  
  90  /***/ 0:
  91  /***/ (function(module, exports) {
  92  
  93  (function() { module.exports = window["wp"]["element"]; }());
  94  
  95  /***/ }),
  96  
  97  /***/ 11:
  98  /***/ (function(module, exports) {
  99  
 100  (function() { module.exports = window["wp"]["compose"]; }());
 101  
 102  /***/ }),
 103  
 104  /***/ 18:
 105  /***/ (function(module, __webpack_exports__, __webpack_require__) {
 106  
 107  "use strict";
 108  /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _assertThisInitialized; });
 109  function _assertThisInitialized(self) {
 110    if (self === void 0) {
 111      throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
 112    }
 113  
 114    return self;
 115  }
 116  
 117  /***/ }),
 118  
 119  /***/ 2:
 120  /***/ (function(module, exports) {
 121  
 122  (function() { module.exports = window["lodash"]; }());
 123  
 124  /***/ }),
 125  
 126  /***/ 22:
 127  /***/ (function(module, __webpack_exports__, __webpack_require__) {
 128  
 129  "use strict";
 130  /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _getPrototypeOf; });
 131  function _getPrototypeOf(o) {
 132    _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) {
 133      return o.__proto__ || Object.getPrototypeOf(o);
 134    };
 135    return _getPrototypeOf(o);
 136  }
 137  
 138  /***/ }),
 139  
 140  /***/ 25:
 141  /***/ (function(module, __webpack_exports__, __webpack_require__) {
 142  
 143  "use strict";
 144  /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _classCallCheck; });
 145  function _classCallCheck(instance, Constructor) {
 146    if (!(instance instanceof Constructor)) {
 147      throw new TypeError("Cannot call a class as a function");
 148    }
 149  }
 150  
 151  /***/ }),
 152  
 153  /***/ 26:
 154  /***/ (function(module, __webpack_exports__, __webpack_require__) {
 155  
 156  "use strict";
 157  /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _createClass; });
 158  function _defineProperties(target, props) {
 159    for (var i = 0; i < props.length; i++) {
 160      var descriptor = props[i];
 161      descriptor.enumerable = descriptor.enumerable || false;
 162      descriptor.configurable = true;
 163      if ("value" in descriptor) descriptor.writable = true;
 164      Object.defineProperty(target, descriptor.key, descriptor);
 165    }
 166  }
 167  
 168  function _createClass(Constructor, protoProps, staticProps) {
 169    if (protoProps) _defineProperties(Constructor.prototype, protoProps);
 170    if (staticProps) _defineProperties(Constructor, staticProps);
 171    return Constructor;
 172  }
 173  
 174  /***/ }),
 175  
 176  /***/ 30:
 177  /***/ (function(module, exports) {
 178  
 179  (function() { module.exports = window["wp"]["hooks"]; }());
 180  
 181  /***/ }),
 182  
 183  /***/ 33:
 184  /***/ (function(module, __webpack_exports__, __webpack_require__) {
 185  
 186  "use strict";
 187  /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _inherits; });
 188  /* harmony import */ var _setPrototypeOf_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(55);
 189  
 190  function _inherits(subClass, superClass) {
 191    if (typeof superClass !== "function" && superClass !== null) {
 192      throw new TypeError("Super expression must either be null or a function");
 193    }
 194  
 195    subClass.prototype = Object.create(superClass && superClass.prototype, {
 196      constructor: {
 197        value: subClass,
 198        writable: true,
 199        configurable: true
 200      }
 201    });
 202    if (superClass) Object(_setPrototypeOf_js__WEBPACK_IMPORTED_MODULE_0__[/* default */ "a"])(subClass, superClass);
 203  }
 204  
 205  /***/ }),
 206  
 207  /***/ 34:
 208  /***/ (function(module, __webpack_exports__, __webpack_require__) {
 209  
 210  "use strict";
 211  /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _possibleConstructorReturn; });
 212  /* harmony import */ var _babel_runtime_helpers_typeof__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(59);
 213  /* harmony import */ var _babel_runtime_helpers_typeof__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_babel_runtime_helpers_typeof__WEBPACK_IMPORTED_MODULE_0__);
 214  /* harmony import */ var _assertThisInitialized_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(18);
 215  
 216  
 217  function _possibleConstructorReturn(self, call) {
 218    if (call && (_babel_runtime_helpers_typeof__WEBPACK_IMPORTED_MODULE_0___default()(call) === "object" || typeof call === "function")) {
 219      return call;
 220    }
 221  
 222    return Object(_assertThisInitialized_js__WEBPACK_IMPORTED_MODULE_1__[/* default */ "a"])(self);
 223  }
 224  
 225  /***/ }),
 226  
 227  /***/ 474:
 228  /***/ (function(module, __webpack_exports__, __webpack_require__) {
 229  
 230  "use strict";
 231  // ESM COMPAT FLAG
 232  __webpack_require__.r(__webpack_exports__);
 233  
 234  // EXPORTS
 235  __webpack_require__.d(__webpack_exports__, "PluginArea", function() { return /* reexport */ plugin_area; });
 236  __webpack_require__.d(__webpack_exports__, "withPluginContext", function() { return /* reexport */ plugin_context_withPluginContext; });
 237  __webpack_require__.d(__webpack_exports__, "registerPlugin", function() { return /* reexport */ registerPlugin; });
 238  __webpack_require__.d(__webpack_exports__, "unregisterPlugin", function() { return /* reexport */ unregisterPlugin; });
 239  __webpack_require__.d(__webpack_exports__, "getPlugin", function() { return /* reexport */ getPlugin; });
 240  __webpack_require__.d(__webpack_exports__, "getPlugins", function() { return /* reexport */ getPlugins; });
 241  
 242  // EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/classCallCheck.js
 243  var classCallCheck = __webpack_require__(25);
 244  
 245  // EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/createClass.js
 246  var createClass = __webpack_require__(26);
 247  
 248  // EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/assertThisInitialized.js
 249  var assertThisInitialized = __webpack_require__(18);
 250  
 251  // EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/inherits.js
 252  var inherits = __webpack_require__(33);
 253  
 254  // EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/possibleConstructorReturn.js
 255  var possibleConstructorReturn = __webpack_require__(34);
 256  
 257  // EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/getPrototypeOf.js
 258  var getPrototypeOf = __webpack_require__(22);
 259  
 260  // EXTERNAL MODULE: external ["wp","element"]
 261  var external_wp_element_ = __webpack_require__(0);
 262  
 263  // EXTERNAL MODULE: external "lodash"
 264  var external_lodash_ = __webpack_require__(2);
 265  
 266  // EXTERNAL MODULE: ./node_modules/memize/index.js
 267  var memize = __webpack_require__(68);
 268  var memize_default = /*#__PURE__*/__webpack_require__.n(memize);
 269  
 270  // EXTERNAL MODULE: external ["wp","hooks"]
 271  var external_wp_hooks_ = __webpack_require__(30);
 272  
 273  // EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/extends.js
 274  var esm_extends = __webpack_require__(8);
 275  
 276  // EXTERNAL MODULE: external ["wp","compose"]
 277  var external_wp_compose_ = __webpack_require__(11);
 278  
 279  // CONCATENATED MODULE: ./node_modules/@wordpress/plugins/build-module/components/plugin-context/index.js
 280  
 281  
 282  
 283  /**
 284   * WordPress dependencies
 285   */
 286  
 287  
 288  
 289  var _createContext = Object(external_wp_element_["createContext"])({
 290    name: null,
 291    icon: null
 292  }),
 293      Consumer = _createContext.Consumer,
 294      Provider = _createContext.Provider;
 295  
 296  
 297  /**
 298   * A Higher Order Component used to inject Plugin context to the
 299   * wrapped component.
 300   *
 301   * @param {Function} mapContextToProps Function called on every context change,
 302   *                                     expected to return object of props to
 303   *                                     merge with the component's own props.
 304   *
 305   * @return {WPComponent} Enhanced component with injected context as props.
 306   */
 307  
 308  var plugin_context_withPluginContext = function withPluginContext(mapContextToProps) {
 309    return Object(external_wp_compose_["createHigherOrderComponent"])(function (OriginalComponent) {
 310      return function (props) {
 311        return Object(external_wp_element_["createElement"])(Consumer, null, function (context) {
 312          return Object(external_wp_element_["createElement"])(OriginalComponent, Object(esm_extends["a" /* default */])({}, props, mapContextToProps(context, props)));
 313        });
 314      };
 315    }, 'withPluginContext');
 316  };
 317  
 318  // EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/defineProperty.js
 319  var defineProperty = __webpack_require__(5);
 320  
 321  // EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/typeof.js
 322  var esm_typeof = __webpack_require__(56);
 323  
 324  // EXTERNAL MODULE: external ["wp","primitives"]
 325  var external_wp_primitives_ = __webpack_require__(7);
 326  
 327  // CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/plugins.js
 328  
 329  
 330  /**
 331   * WordPress dependencies
 332   */
 333  
 334  var plugins = Object(external_wp_element_["createElement"])(external_wp_primitives_["SVG"], {
 335    xmlns: "http://www.w3.org/2000/svg",
 336    viewBox: "0 0 24 24"
 337  }, Object(external_wp_element_["createElement"])(external_wp_primitives_["Path"], {
 338    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"
 339  }));
 340  /* harmony default export */ var library_plugins = (plugins);
 341  
 342  // CONCATENATED MODULE: ./node_modules/@wordpress/plugins/build-module/api/index.js
 343  
 344  
 345  
 346  function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
 347  
 348  function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { Object(defineProperty["a" /* default */])(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
 349  
 350  /* eslint no-console: [ 'error', { allow: [ 'error' ] } ] */
 351  
 352  /**
 353   * WordPress dependencies
 354   */
 355  
 356  
 357  /**
 358   * External dependencies
 359   */
 360  
 361  
 362  /**
 363   * Defined behavior of a plugin type.
 364   *
 365   * @typedef {Object} WPPlugin
 366   *
 367   * @property {string}                    name    A string identifying the plugin. Must be
 368   *                                               unique across all registered plugins.
 369   * @property {string|WPElement|Function} [icon]  An icon to be shown in the UI. It can
 370   *                                               be a slug of the Dashicon, or an element
 371   *                                               (or function returning an element) if you
 372   *                                               choose to render your own SVG.
 373   * @property {Function}                  render  A component containing the UI elements
 374   *                                               to be rendered.
 375   * @property {string}                    [scope] The optional scope to be used when rendering inside
 376   *                                               a plugin area. No scope by default.
 377   */
 378  
 379  /**
 380   * Plugin definitions keyed by plugin name.
 381   *
 382   * @type {Object.<string,WPPlugin>}
 383   */
 384  
 385  var api_plugins = {};
 386  /**
 387   * Registers a plugin to the editor.
 388   *
 389   * @param {string}   name     A string identifying the plugin.Must be
 390   *                            unique across all registered plugins.
 391   * @param {WPPlugin} settings The settings for this plugin.
 392   *
 393   * @example
 394   * ```js
 395   * // Using ES5 syntax
 396   * var el = wp.element.createElement;
 397   * var Fragment = wp.element.Fragment;
 398   * var PluginSidebar = wp.editPost.PluginSidebar;
 399   * var PluginSidebarMoreMenuItem = wp.editPost.PluginSidebarMoreMenuItem;
 400   * var registerPlugin = wp.plugins.registerPlugin;
 401   * var moreIcon = wp.element.createElement( 'svg' ); //... svg element.
 402   *
 403   * function Component() {
 404   *     return el(
 405   *         Fragment,
 406   *         {},
 407   *         el(
 408   *             PluginSidebarMoreMenuItem,
 409   *             {
 410   *                 target: 'sidebar-name',
 411   *             },
 412   *             'My Sidebar'
 413   *         ),
 414   *         el(
 415   *             PluginSidebar,
 416   *             {
 417   *                 name: 'sidebar-name',
 418   *                 title: 'My Sidebar',
 419   *             },
 420   *             'Content of the sidebar'
 421   *         )
 422   *     );
 423   * }
 424   * registerPlugin( 'plugin-name', {
 425   *     icon: moreIcon,
 426   *     render: Component,
 427   *     scope: 'my-page',
 428   * } );
 429   * ```
 430   *
 431   * @example
 432   * ```js
 433   * // Using ESNext syntax
 434   * import { PluginSidebar, PluginSidebarMoreMenuItem } from '@wordpress/edit-post';
 435   * import { registerPlugin } from '@wordpress/plugins';
 436   * import { more } from '@wordpress/icons';
 437   *
 438   * const Component = () => (
 439   *     <>
 440   *         <PluginSidebarMoreMenuItem
 441   *             target="sidebar-name"
 442   *         >
 443   *             My Sidebar
 444   *         </PluginSidebarMoreMenuItem>
 445   *         <PluginSidebar
 446   *             name="sidebar-name"
 447   *             title="My Sidebar"
 448   *         >
 449   *             Content of the sidebar
 450   *         </PluginSidebar>
 451   *     </>
 452   * );
 453   *
 454   * registerPlugin( 'plugin-name', {
 455   *     icon: more,
 456   *     render: Component,
 457   *     scope: 'my-page',
 458   * } );
 459   * ```
 460   *
 461   * @return {WPPlugin} The final plugin settings object.
 462   */
 463  
 464  function registerPlugin(name, settings) {
 465    if (Object(esm_typeof["a" /* default */])(settings) !== 'object') {
 466      console.error('No settings object provided!');
 467      return null;
 468    }
 469  
 470    if (typeof name !== 'string') {
 471      console.error('Plugin name must be string.');
 472      return null;
 473    }
 474  
 475    if (!/^[a-z][a-z0-9-]*$/.test(name)) {
 476      console.error('Plugin name must include only lowercase alphanumeric characters or dashes, and start with a letter. Example: "my-plugin".');
 477      return null;
 478    }
 479  
 480    if (api_plugins[name]) {
 481      console.error("Plugin \"".concat(name, "\" is already registered."));
 482    }
 483  
 484    settings = Object(external_wp_hooks_["applyFilters"])('plugins.registerPlugin', settings, name);
 485    var _settings = settings,
 486        render = _settings.render,
 487        scope = _settings.scope;
 488  
 489    if (!Object(external_lodash_["isFunction"])(render)) {
 490      console.error('The "render" property must be specified and must be a valid function.');
 491      return null;
 492    }
 493  
 494    if (scope) {
 495      if (typeof scope !== 'string') {
 496        console.error('Plugin scope must be string.');
 497        return null;
 498      }
 499  
 500      if (!/^[a-z][a-z0-9-]*$/.test(scope)) {
 501        console.error('Plugin scope must include only lowercase alphanumeric characters or dashes, and start with a letter. Example: "my-page".');
 502        return null;
 503      }
 504    }
 505  
 506    api_plugins[name] = _objectSpread({
 507      name: name,
 508      icon: library_plugins
 509    }, settings);
 510    Object(external_wp_hooks_["doAction"])('plugins.pluginRegistered', settings, name);
 511    return settings;
 512  }
 513  /**
 514   * Unregisters a plugin by name.
 515   *
 516   * @param {string} name Plugin name.
 517   *
 518   * @example
 519   * ```js
 520   * // Using ES5 syntax
 521   * var unregisterPlugin = wp.plugins.unregisterPlugin;
 522   *
 523   * unregisterPlugin( 'plugin-name' );
 524   * ```
 525   *
 526   * @example
 527   * ```js
 528   * // Using ESNext syntax
 529   * import { unregisterPlugin } from '@wordpress/plugins';
 530   *
 531   * unregisterPlugin( 'plugin-name' );
 532   * ```
 533   *
 534   * @return {?WPPlugin} The previous plugin settings object, if it has been
 535   *                     successfully unregistered; otherwise `undefined`.
 536   */
 537  
 538  function unregisterPlugin(name) {
 539    if (!api_plugins[name]) {
 540      console.error('Plugin "' + name + '" is not registered.');
 541      return;
 542    }
 543  
 544    var oldPlugin = api_plugins[name];
 545    delete api_plugins[name];
 546    Object(external_wp_hooks_["doAction"])('plugins.pluginUnregistered', oldPlugin, name);
 547    return oldPlugin;
 548  }
 549  /**
 550   * Returns a registered plugin settings.
 551   *
 552   * @param {string} name Plugin name.
 553   *
 554   * @return {?WPPlugin} Plugin setting.
 555   */
 556  
 557  function getPlugin(name) {
 558    return api_plugins[name];
 559  }
 560  /**
 561   * Returns all registered plugins without a scope or for a given scope.
 562   *
 563   * @param {string} [scope] The scope to be used when rendering inside
 564   *                         a plugin area. No scope by default.
 565   *
 566   * @return {WPPlugin[]} The list of plugins without a scope or for a given scope.
 567   */
 568  
 569  function getPlugins(scope) {
 570    return Object.values(api_plugins).filter(function (plugin) {
 571      return plugin.scope === scope;
 572    });
 573  }
 574  
 575  // CONCATENATED MODULE: ./node_modules/@wordpress/plugins/build-module/components/plugin-area/index.js
 576  
 577  
 578  
 579  
 580  
 581  
 582  
 583  
 584  function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = Object(getPrototypeOf["a" /* default */])(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = Object(getPrototypeOf["a" /* default */])(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return Object(possibleConstructorReturn["a" /* default */])(this, result); }; }
 585  
 586  function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
 587  
 588  /**
 589   * External dependencies
 590   */
 591  
 592  
 593  /**
 594   * WordPress dependencies
 595   */
 596  
 597  
 598  
 599  /**
 600   * Internal dependencies
 601   */
 602  
 603  
 604  
 605  /**
 606   * A component that renders all plugin fills in a hidden div.
 607   *
 608   * @example
 609   * ```js
 610   * // Using ES5 syntax
 611   * var el = wp.element.createElement;
 612   * var PluginArea = wp.plugins.PluginArea;
 613   *
 614   * function Layout() {
 615   *     return el(
 616   *         'div',
 617   *         { scope: 'my-page' },
 618   *         'Content of the page',
 619   *         PluginArea
 620   *     );
 621   * }
 622   * ```
 623   *
 624   * @example
 625   * ```js
 626   * // Using ESNext syntax
 627   * import { PluginArea } from '@wordpress/plugins';
 628   *
 629   * const Layout = () => (
 630   *     <div>
 631   *         Content of the page
 632   *         <PluginArea scope="my-page" />
 633   *     </div>
 634   * );
 635   * ```
 636   *
 637   * @return {WPComponent} The component to be rendered.
 638   */
 639  
 640  var plugin_area_PluginArea = /*#__PURE__*/function (_Component) {
 641    Object(inherits["a" /* default */])(PluginArea, _Component);
 642  
 643    var _super = _createSuper(PluginArea);
 644  
 645    function PluginArea() {
 646      var _this;
 647  
 648      Object(classCallCheck["a" /* default */])(this, PluginArea);
 649  
 650      _this = _super.apply(this, arguments);
 651      _this.setPlugins = _this.setPlugins.bind(Object(assertThisInitialized["a" /* default */])(_this));
 652      _this.memoizedContext = memize_default()(function (name, icon) {
 653        return {
 654          name: name,
 655          icon: icon
 656        };
 657      });
 658      _this.state = _this.getCurrentPluginsState();
 659      return _this;
 660    }
 661  
 662    Object(createClass["a" /* default */])(PluginArea, [{
 663      key: "getCurrentPluginsState",
 664      value: function getCurrentPluginsState() {
 665        var _this2 = this;
 666  
 667        return {
 668          plugins: Object(external_lodash_["map"])(getPlugins(this.props.scope), function (_ref) {
 669            var icon = _ref.icon,
 670                name = _ref.name,
 671                render = _ref.render;
 672            return {
 673              Plugin: render,
 674              context: _this2.memoizedContext(name, icon)
 675            };
 676          })
 677        };
 678      }
 679    }, {
 680      key: "componentDidMount",
 681      value: function componentDidMount() {
 682        Object(external_wp_hooks_["addAction"])('plugins.pluginRegistered', 'core/plugins/plugin-area/plugins-registered', this.setPlugins);
 683        Object(external_wp_hooks_["addAction"])('plugins.pluginUnregistered', 'core/plugins/plugin-area/plugins-unregistered', this.setPlugins);
 684      }
 685    }, {
 686      key: "componentWillUnmount",
 687      value: function componentWillUnmount() {
 688        Object(external_wp_hooks_["removeAction"])('plugins.pluginRegistered', 'core/plugins/plugin-area/plugins-registered');
 689        Object(external_wp_hooks_["removeAction"])('plugins.pluginUnregistered', 'core/plugins/plugin-area/plugins-unregistered');
 690      }
 691    }, {
 692      key: "setPlugins",
 693      value: function setPlugins() {
 694        this.setState(this.getCurrentPluginsState);
 695      }
 696    }, {
 697      key: "render",
 698      value: function render() {
 699        return Object(external_wp_element_["createElement"])("div", {
 700          style: {
 701            display: 'none'
 702          }
 703        }, Object(external_lodash_["map"])(this.state.plugins, function (_ref2) {
 704          var context = _ref2.context,
 705              Plugin = _ref2.Plugin;
 706          return Object(external_wp_element_["createElement"])(Provider, {
 707            key: context.name,
 708            value: context
 709          }, Object(external_wp_element_["createElement"])(Plugin, null));
 710        }));
 711      }
 712    }]);
 713  
 714    return PluginArea;
 715  }(external_wp_element_["Component"]);
 716  
 717  /* harmony default export */ var plugin_area = (plugin_area_PluginArea);
 718  
 719  // CONCATENATED MODULE: ./node_modules/@wordpress/plugins/build-module/components/index.js
 720  
 721  
 722  
 723  // CONCATENATED MODULE: ./node_modules/@wordpress/plugins/build-module/index.js
 724  
 725  
 726  
 727  
 728  /***/ }),
 729  
 730  /***/ 5:
 731  /***/ (function(module, __webpack_exports__, __webpack_require__) {
 732  
 733  "use strict";
 734  /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _defineProperty; });
 735  function _defineProperty(obj, key, value) {
 736    if (key in obj) {
 737      Object.defineProperty(obj, key, {
 738        value: value,
 739        enumerable: true,
 740        configurable: true,
 741        writable: true
 742      });
 743    } else {
 744      obj[key] = value;
 745    }
 746  
 747    return obj;
 748  }
 749  
 750  /***/ }),
 751  
 752  /***/ 55:
 753  /***/ (function(module, __webpack_exports__, __webpack_require__) {
 754  
 755  "use strict";
 756  /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _setPrototypeOf; });
 757  function _setPrototypeOf(o, p) {
 758    _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) {
 759      o.__proto__ = p;
 760      return o;
 761    };
 762  
 763    return _setPrototypeOf(o, p);
 764  }
 765  
 766  /***/ }),
 767  
 768  /***/ 56:
 769  /***/ (function(module, __webpack_exports__, __webpack_require__) {
 770  
 771  "use strict";
 772  /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _typeof; });
 773  function _typeof(obj) {
 774    "@babel/helpers - typeof";
 775  
 776    if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") {
 777      _typeof = function _typeof(obj) {
 778        return typeof obj;
 779      };
 780    } else {
 781      _typeof = function _typeof(obj) {
 782        return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
 783      };
 784    }
 785  
 786    return _typeof(obj);
 787  }
 788  
 789  /***/ }),
 790  
 791  /***/ 59:
 792  /***/ (function(module, exports) {
 793  
 794  function _typeof(obj) {
 795    "@babel/helpers - typeof";
 796  
 797    if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") {
 798      module.exports = _typeof = function _typeof(obj) {
 799        return typeof obj;
 800      };
 801  
 802      module.exports["default"] = module.exports, module.exports.__esModule = true;
 803    } else {
 804      module.exports = _typeof = function _typeof(obj) {
 805        return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
 806      };
 807  
 808      module.exports["default"] = module.exports, module.exports.__esModule = true;
 809    }
 810  
 811    return _typeof(obj);
 812  }
 813  
 814  module.exports = _typeof;
 815  module.exports["default"] = module.exports, module.exports.__esModule = true;
 816  
 817  /***/ }),
 818  
 819  /***/ 68:
 820  /***/ (function(module, exports, __webpack_require__) {
 821  
 822  /**
 823   * Memize options object.
 824   *
 825   * @typedef MemizeOptions
 826   *
 827   * @property {number} [maxSize] Maximum size of the cache.
 828   */
 829  
 830  /**
 831   * Internal cache entry.
 832   *
 833   * @typedef MemizeCacheNode
 834   *
 835   * @property {?MemizeCacheNode|undefined} [prev] Previous node.
 836   * @property {?MemizeCacheNode|undefined} [next] Next node.
 837   * @property {Array<*>}                   args   Function arguments for cache
 838   *                                               entry.
 839   * @property {*}                          val    Function result.
 840   */
 841  
 842  /**
 843   * Properties of the enhanced function for controlling cache.
 844   *
 845   * @typedef MemizeMemoizedFunction
 846   *
 847   * @property {()=>void} clear Clear the cache.
 848   */
 849  
 850  /**
 851   * Accepts a function to be memoized, and returns a new memoized function, with
 852   * optional options.
 853   *
 854   * @template {Function} F
 855   *
 856   * @param {F}             fn        Function to memoize.
 857   * @param {MemizeOptions} [options] Options object.
 858   *
 859   * @return {F & MemizeMemoizedFunction} Memoized function.
 860   */
 861  function memize( fn, options ) {
 862      var size = 0;
 863  
 864      /** @type {?MemizeCacheNode|undefined} */
 865      var head;
 866  
 867      /** @type {?MemizeCacheNode|undefined} */
 868      var tail;
 869  
 870      options = options || {};
 871  
 872  	function memoized( /* ...args */ ) {
 873          var node = head,
 874              len = arguments.length,
 875              args, i;
 876  
 877          searchCache: while ( node ) {
 878              // Perform a shallow equality test to confirm that whether the node
 879              // under test is a candidate for the arguments passed. Two arrays
 880              // are shallowly equal if their length matches and each entry is
 881              // strictly equal between the two sets. Avoid abstracting to a
 882              // function which could incur an arguments leaking deoptimization.
 883  
 884              // Check whether node arguments match arguments length
 885              if ( node.args.length !== arguments.length ) {
 886                  node = node.next;
 887                  continue;
 888              }
 889  
 890              // Check whether node arguments match arguments values
 891              for ( i = 0; i < len; i++ ) {
 892                  if ( node.args[ i ] !== arguments[ i ] ) {
 893                      node = node.next;
 894                      continue searchCache;
 895                  }
 896              }
 897  
 898              // At this point we can assume we've found a match
 899  
 900              // Surface matched node to head if not already
 901              if ( node !== head ) {
 902                  // As tail, shift to previous. Must only shift if not also
 903                  // head, since if both head and tail, there is no previous.
 904                  if ( node === tail ) {
 905                      tail = node.prev;
 906                  }
 907  
 908                  // Adjust siblings to point to each other. If node was tail,
 909                  // this also handles new tail's empty `next` assignment.
 910                  /** @type {MemizeCacheNode} */ ( node.prev ).next = node.next;
 911                  if ( node.next ) {
 912                      node.next.prev = node.prev;
 913                  }
 914  
 915                  node.next = head;
 916                  node.prev = null;
 917                  /** @type {MemizeCacheNode} */ ( head ).prev = node;
 918                  head = node;
 919              }
 920  
 921              // Return immediately
 922              return node.val;
 923          }
 924  
 925          // No cached value found. Continue to insertion phase:
 926  
 927          // Create a copy of arguments (avoid leaking deoptimization)
 928          args = new Array( len );
 929          for ( i = 0; i < len; i++ ) {
 930              args[ i ] = arguments[ i ];
 931          }
 932  
 933          node = {
 934              args: args,
 935  
 936              // Generate the result from original function
 937              val: fn.apply( null, args ),
 938          };
 939  
 940          // Don't need to check whether node is already head, since it would
 941          // have been returned above already if it was
 942  
 943          // Shift existing head down list
 944          if ( head ) {
 945              head.prev = node;
 946              node.next = head;
 947          } else {
 948              // If no head, follows that there's no tail (at initial or reset)
 949              tail = node;
 950          }
 951  
 952          // Trim tail if we're reached max size and are pending cache insertion
 953          if ( size === /** @type {MemizeOptions} */ ( options ).maxSize ) {
 954              tail = /** @type {MemizeCacheNode} */ ( tail ).prev;
 955              /** @type {MemizeCacheNode} */ ( tail ).next = null;
 956          } else {
 957              size++;
 958          }
 959  
 960          head = node;
 961  
 962          return node.val;
 963      }
 964  
 965      memoized.clear = function() {
 966          head = null;
 967          tail = null;
 968          size = 0;
 969      };
 970  
 971      if ( false ) {}
 972  
 973      // Ignore reason: There's not a clear solution to create an intersection of
 974      // the function with additional properties, where the goal is to retain the
 975      // function signature of the incoming argument and add control properties
 976      // on the return value.
 977  
 978      // @ts-ignore
 979      return memoized;
 980  }
 981  
 982  module.exports = memize;
 983  
 984  
 985  /***/ }),
 986  
 987  /***/ 7:
 988  /***/ (function(module, exports) {
 989  
 990  (function() { module.exports = window["wp"]["primitives"]; }());
 991  
 992  /***/ }),
 993  
 994  /***/ 8:
 995  /***/ (function(module, __webpack_exports__, __webpack_require__) {
 996  
 997  "use strict";
 998  /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _extends; });
 999  function _extends() {
1000    _extends = Object.assign || function (target) {
1001      for (var i = 1; i < arguments.length; i++) {
1002        var source = arguments[i];
1003  
1004        for (var key in source) {
1005          if (Object.prototype.hasOwnProperty.call(source, key)) {
1006            target[key] = source[key];
1007          }
1008        }
1009      }
1010  
1011      return target;
1012    };
1013  
1014    return _extends.apply(this, arguments);
1015  }
1016  
1017  /***/ })
1018  
1019  /******/ });


Generated: Sat May 15 01:00:05 2021 Cross-referenced by PHPXref 0.7.1