You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

641 lines
18 KiB

1 year ago
  1. /******/ (function() { // webpackBootstrap
  2. /******/ "use strict";
  3. /******/ // The require scope
  4. /******/ var __webpack_require__ = {};
  5. /******/
  6. /************************************************************************/
  7. /******/ /* webpack/runtime/compat get default export */
  8. /******/ !function() {
  9. /******/ // getDefaultExport function for compatibility with non-harmony modules
  10. /******/ __webpack_require__.n = function(module) {
  11. /******/ var getter = module && module.__esModule ?
  12. /******/ function() { return module['default']; } :
  13. /******/ function() { return module; };
  14. /******/ __webpack_require__.d(getter, { a: getter });
  15. /******/ return getter;
  16. /******/ };
  17. /******/ }();
  18. /******/
  19. /******/ /* webpack/runtime/define property getters */
  20. /******/ !function() {
  21. /******/ // define getter functions for harmony exports
  22. /******/ __webpack_require__.d = function(exports, definition) {
  23. /******/ for(var key in definition) {
  24. /******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
  25. /******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
  26. /******/ }
  27. /******/ }
  28. /******/ };
  29. /******/ }();
  30. /******/
  31. /******/ /* webpack/runtime/hasOwnProperty shorthand */
  32. /******/ !function() {
  33. /******/ __webpack_require__.o = function(obj, prop) { return Object.prototype.hasOwnProperty.call(obj, prop); }
  34. /******/ }();
  35. /******/
  36. /******/ /* webpack/runtime/make namespace object */
  37. /******/ !function() {
  38. /******/ // define __esModule on exports
  39. /******/ __webpack_require__.r = function(exports) {
  40. /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
  41. /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
  42. /******/ }
  43. /******/ Object.defineProperty(exports, '__esModule', { value: true });
  44. /******/ };
  45. /******/ }();
  46. /******/
  47. /************************************************************************/
  48. var __webpack_exports__ = {};
  49. // ESM COMPAT FLAG
  50. __webpack_require__.r(__webpack_exports__);
  51. // EXPORTS
  52. __webpack_require__.d(__webpack_exports__, {
  53. PluginArea: function() { return /* reexport */ plugin_area; },
  54. getPlugin: function() { return /* reexport */ getPlugin; },
  55. getPlugins: function() { return /* reexport */ getPlugins; },
  56. registerPlugin: function() { return /* reexport */ registerPlugin; },
  57. unregisterPlugin: function() { return /* reexport */ unregisterPlugin; },
  58. usePluginContext: function() { return /* reexport */ usePluginContext; },
  59. withPluginContext: function() { return /* reexport */ withPluginContext; }
  60. });
  61. ;// CONCATENATED MODULE: external ["wp","element"]
  62. var external_wp_element_namespaceObject = window["wp"]["element"];
  63. ;// CONCATENATED MODULE: ./node_modules/memize/dist/index.js
  64. /**
  65. * Memize options object.
  66. *
  67. * @typedef MemizeOptions
  68. *
  69. * @property {number} [maxSize] Maximum size of the cache.
  70. */
  71. /**
  72. * Internal cache entry.
  73. *
  74. * @typedef MemizeCacheNode
  75. *
  76. * @property {?MemizeCacheNode|undefined} [prev] Previous node.
  77. * @property {?MemizeCacheNode|undefined} [next] Next node.
  78. * @property {Array<*>} args Function arguments for cache
  79. * entry.
  80. * @property {*} val Function result.
  81. */
  82. /**
  83. * Properties of the enhanced function for controlling cache.
  84. *
  85. * @typedef MemizeMemoizedFunction
  86. *
  87. * @property {()=>void} clear Clear the cache.
  88. */
  89. /**
  90. * Accepts a function to be memoized, and returns a new memoized function, with
  91. * optional options.
  92. *
  93. * @template {(...args: any[]) => any} F
  94. *
  95. * @param {F} fn Function to memoize.
  96. * @param {MemizeOptions} [options] Options object.
  97. *
  98. * @return {((...args: Parameters<F>) => ReturnType<F>) & MemizeMemoizedFunction} Memoized function.
  99. */
  100. function memize(fn, options) {
  101. var size = 0;
  102. /** @type {?MemizeCacheNode|undefined} */
  103. var head;
  104. /** @type {?MemizeCacheNode|undefined} */
  105. var tail;
  106. options = options || {};
  107. function memoized(/* ...args */) {
  108. var node = head,
  109. len = arguments.length,
  110. args,
  111. i;
  112. searchCache: while (node) {
  113. // Perform a shallow equality test to confirm that whether the node
  114. // under test is a candidate for the arguments passed. Two arrays
  115. // are shallowly equal if their length matches and each entry is
  116. // strictly equal between the two sets. Avoid abstracting to a
  117. // function which could incur an arguments leaking deoptimization.
  118. // Check whether node arguments match arguments length
  119. if (node.args.length !== arguments.length) {
  120. node = node.next;
  121. continue;
  122. }
  123. // Check whether node arguments match arguments values
  124. for (i = 0; i < len; i++) {
  125. if (node.args[i] !== arguments[i]) {
  126. node = node.next;
  127. continue searchCache;
  128. }
  129. }
  130. // At this point we can assume we've found a match
  131. // Surface matched node to head if not already
  132. if (node !== head) {
  133. // As tail, shift to previous. Must only shift if not also
  134. // head, since if both head and tail, there is no previous.
  135. if (node === tail) {
  136. tail = node.prev;
  137. }
  138. // Adjust siblings to point to each other. If node was tail,
  139. // this also handles new tail's empty `next` assignment.
  140. /** @type {MemizeCacheNode} */ (node.prev).next = node.next;
  141. if (node.next) {
  142. node.next.prev = node.prev;
  143. }
  144. node.next = head;
  145. node.prev = null;
  146. /** @type {MemizeCacheNode} */ (head).prev = node;
  147. head = node;
  148. }
  149. // Return immediately
  150. return node.val;
  151. }
  152. // No cached value found. Continue to insertion phase:
  153. // Create a copy of arguments (avoid leaking deoptimization)
  154. args = new Array(len);
  155. for (i = 0; i < len; i++) {
  156. args[i] = arguments[i];
  157. }
  158. node = {
  159. args: args,
  160. // Generate the result from original function
  161. val: fn.apply(null, args),
  162. };
  163. // Don't need to check whether node is already head, since it would
  164. // have been returned above already if it was
  165. // Shift existing head down list
  166. if (head) {
  167. head.prev = node;
  168. node.next = head;
  169. } else {
  170. // If no head, follows that there's no tail (at initial or reset)
  171. tail = node;
  172. }
  173. // Trim tail if we're reached max size and are pending cache insertion
  174. if (size === /** @type {MemizeOptions} */ (options).maxSize) {
  175. tail = /** @type {MemizeCacheNode} */ (tail).prev;
  176. /** @type {MemizeCacheNode} */ (tail).next = null;
  177. } else {
  178. size++;
  179. }
  180. head = node;
  181. return node.val;
  182. }
  183. memoized.clear = function () {
  184. head = null;
  185. tail = null;
  186. size = 0;
  187. };
  188. // Ignore reason: There's not a clear solution to create an intersection of
  189. // the function with additional properties, where the goal is to retain the
  190. // function signature of the incoming argument and add control properties
  191. // on the return value.
  192. // @ts-ignore
  193. return memoized;
  194. }
  195. ;// CONCATENATED MODULE: external ["wp","hooks"]
  196. var external_wp_hooks_namespaceObject = window["wp"]["hooks"];
  197. ;// CONCATENATED MODULE: external ["wp","isShallowEqual"]
  198. var external_wp_isShallowEqual_namespaceObject = window["wp"]["isShallowEqual"];
  199. var external_wp_isShallowEqual_default = /*#__PURE__*/__webpack_require__.n(external_wp_isShallowEqual_namespaceObject);
  200. ;// CONCATENATED MODULE: external ["wp","compose"]
  201. var external_wp_compose_namespaceObject = window["wp"]["compose"];
  202. ;// CONCATENATED MODULE: ./node_modules/@wordpress/plugins/build-module/components/plugin-context/index.js
  203. /**
  204. * WordPress dependencies
  205. */
  206. /**
  207. * Internal dependencies
  208. */
  209. const Context = (0,external_wp_element_namespaceObject.createContext)({
  210. name: null,
  211. icon: null
  212. });
  213. const PluginContextProvider = Context.Provider;
  214. /**
  215. * A hook that returns the plugin context.
  216. *
  217. * @return {PluginContext} Plugin context
  218. */
  219. function usePluginContext() {
  220. return (0,external_wp_element_namespaceObject.useContext)(Context);
  221. }
  222. /**
  223. * A Higher Order Component used to inject Plugin context to the
  224. * wrapped component.
  225. *
  226. * @param mapContextToProps Function called on every context change,
  227. * expected to return object of props to
  228. * merge with the component's own props.
  229. *
  230. * @return {WPComponent} Enhanced component with injected context as props.
  231. */
  232. const withPluginContext = mapContextToProps => (0,external_wp_compose_namespaceObject.createHigherOrderComponent)(OriginalComponent => {
  233. return props => (0,external_wp_element_namespaceObject.createElement)(Context.Consumer, null, context => (0,external_wp_element_namespaceObject.createElement)(OriginalComponent, {
  234. ...props,
  235. ...mapContextToProps(context, props)
  236. }));
  237. }, 'withPluginContext');
  238. ;// CONCATENATED MODULE: ./node_modules/@wordpress/plugins/build-module/components/plugin-error-boundary/index.js
  239. /**
  240. * WordPress dependencies
  241. */
  242. class PluginErrorBoundary extends external_wp_element_namespaceObject.Component {
  243. /**
  244. * @param {Object} props
  245. */
  246. constructor(props) {
  247. super(props);
  248. this.state = {
  249. hasError: false
  250. };
  251. }
  252. static getDerivedStateFromError() {
  253. return {
  254. hasError: true
  255. };
  256. }
  257. /**
  258. * @param {Error} error Error object passed by React.
  259. */
  260. componentDidCatch(error) {
  261. const {
  262. name,
  263. onError
  264. } = this.props;
  265. if (onError) {
  266. onError(name, error);
  267. }
  268. }
  269. render() {
  270. if (!this.state.hasError) {
  271. return this.props.children;
  272. }
  273. return null;
  274. }
  275. }
  276. ;// CONCATENATED MODULE: external ["wp","primitives"]
  277. var external_wp_primitives_namespaceObject = window["wp"]["primitives"];
  278. ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/plugins.js
  279. /**
  280. * WordPress dependencies
  281. */
  282. const plugins = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
  283. xmlns: "http://www.w3.org/2000/svg",
  284. viewBox: "0 0 24 24"
  285. }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
  286. 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"
  287. }));
  288. /* harmony default export */ var library_plugins = (plugins);
  289. ;// CONCATENATED MODULE: ./node_modules/@wordpress/plugins/build-module/api/index.js
  290. /* eslint no-console: [ 'error', { allow: [ 'error' ] } ] */
  291. /**
  292. * WordPress dependencies
  293. */
  294. /**
  295. * Plugin definitions keyed by plugin name.
  296. */
  297. const api_plugins = {};
  298. /**
  299. * Registers a plugin to the editor.
  300. *
  301. * @param name A string identifying the plugin. Must be
  302. * unique across all registered plugins.
  303. * @param settings The settings for this plugin.
  304. *
  305. * @example
  306. * ```js
  307. * // Using ES5 syntax
  308. * var el = wp.element.createElement;
  309. * var Fragment = wp.element.Fragment;
  310. * var PluginSidebar = wp.editPost.PluginSidebar;
  311. * var PluginSidebarMoreMenuItem = wp.editPost.PluginSidebarMoreMenuItem;
  312. * var registerPlugin = wp.plugins.registerPlugin;
  313. * var moreIcon = wp.element.createElement( 'svg' ); //... svg element.
  314. *
  315. * function Component() {
  316. * return el(
  317. * Fragment,
  318. * {},
  319. * el(
  320. * PluginSidebarMoreMenuItem,
  321. * {
  322. * target: 'sidebar-name',
  323. * },
  324. * 'My Sidebar'
  325. * ),
  326. * el(
  327. * PluginSidebar,
  328. * {
  329. * name: 'sidebar-name',
  330. * title: 'My Sidebar',
  331. * },
  332. * 'Content of the sidebar'
  333. * )
  334. * );
  335. * }
  336. * registerPlugin( 'plugin-name', {
  337. * icon: moreIcon,
  338. * render: Component,
  339. * scope: 'my-page',
  340. * } );
  341. * ```
  342. *
  343. * @example
  344. * ```js
  345. * // Using ESNext syntax
  346. * import { PluginSidebar, PluginSidebarMoreMenuItem } from '@wordpress/edit-post';
  347. * import { registerPlugin } from '@wordpress/plugins';
  348. * import { more } from '@wordpress/icons';
  349. *
  350. * const Component = () => (
  351. * <>
  352. * <PluginSidebarMoreMenuItem
  353. * target="sidebar-name"
  354. * >
  355. * My Sidebar
  356. * </PluginSidebarMoreMenuItem>
  357. * <PluginSidebar
  358. * name="sidebar-name"
  359. * title="My Sidebar"
  360. * >
  361. * Content of the sidebar
  362. * </PluginSidebar>
  363. * </>
  364. * );
  365. *
  366. * registerPlugin( 'plugin-name', {
  367. * icon: more,
  368. * render: Component,
  369. * scope: 'my-page',
  370. * } );
  371. * ```
  372. *
  373. * @return The final plugin settings object.
  374. */
  375. function registerPlugin(name, settings) {
  376. if (typeof settings !== 'object') {
  377. console.error('No settings object provided!');
  378. return null;
  379. }
  380. if (typeof name !== 'string') {
  381. console.error('Plugin name must be string.');
  382. return null;
  383. }
  384. if (!/^[a-z][a-z0-9-]*$/.test(name)) {
  385. console.error('Plugin name must include only lowercase alphanumeric characters or dashes, and start with a letter. Example: "my-plugin".');
  386. return null;
  387. }
  388. if (api_plugins[name]) {
  389. console.error(`Plugin "${name}" is already registered.`);
  390. }
  391. settings = (0,external_wp_hooks_namespaceObject.applyFilters)('plugins.registerPlugin', settings, name);
  392. const {
  393. render,
  394. scope
  395. } = settings;
  396. if (typeof render !== 'function') {
  397. console.error('The "render" property must be specified and must be a valid function.');
  398. return null;
  399. }
  400. if (scope) {
  401. if (typeof scope !== 'string') {
  402. console.error('Plugin scope must be string.');
  403. return null;
  404. }
  405. if (!/^[a-z][a-z0-9-]*$/.test(scope)) {
  406. console.error('Plugin scope must include only lowercase alphanumeric characters or dashes, and start with a letter. Example: "my-page".');
  407. return null;
  408. }
  409. }
  410. api_plugins[name] = {
  411. name,
  412. icon: library_plugins,
  413. ...settings
  414. };
  415. (0,external_wp_hooks_namespaceObject.doAction)('plugins.pluginRegistered', settings, name);
  416. return settings;
  417. }
  418. /**
  419. * Unregisters a plugin by name.
  420. *
  421. * @param name Plugin name.
  422. *
  423. * @example
  424. * ```js
  425. * // Using ES5 syntax
  426. * var unregisterPlugin = wp.plugins.unregisterPlugin;
  427. *
  428. * unregisterPlugin( 'plugin-name' );
  429. * ```
  430. *
  431. * @example
  432. * ```js
  433. * // Using ESNext syntax
  434. * import { unregisterPlugin } from '@wordpress/plugins';
  435. *
  436. * unregisterPlugin( 'plugin-name' );
  437. * ```
  438. *
  439. * @return The previous plugin settings object, if it has been
  440. * successfully unregistered; otherwise `undefined`.
  441. */
  442. function unregisterPlugin(name) {
  443. if (!api_plugins[name]) {
  444. console.error('Plugin "' + name + '" is not registered.');
  445. return;
  446. }
  447. const oldPlugin = api_plugins[name];
  448. delete api_plugins[name];
  449. (0,external_wp_hooks_namespaceObject.doAction)('plugins.pluginUnregistered', oldPlugin, name);
  450. return oldPlugin;
  451. }
  452. /**
  453. * Returns a registered plugin settings.
  454. *
  455. * @param name Plugin name.
  456. *
  457. * @return Plugin setting.
  458. */
  459. function getPlugin(name) {
  460. return api_plugins[name];
  461. }
  462. /**
  463. * Returns all registered plugins without a scope or for a given scope.
  464. *
  465. * @param scope The scope to be used when rendering inside
  466. * a plugin area. No scope by default.
  467. *
  468. * @return The list of plugins without a scope or for a given scope.
  469. */
  470. function getPlugins(scope) {
  471. return Object.values(api_plugins).filter(plugin => plugin.scope === scope);
  472. }
  473. ;// CONCATENATED MODULE: ./node_modules/@wordpress/plugins/build-module/components/plugin-area/index.js
  474. /**
  475. * External dependencies
  476. */
  477. /**
  478. * WordPress dependencies
  479. */
  480. /**
  481. * Internal dependencies
  482. */
  483. const getPluginContext = memize((icon, name) => ({
  484. icon,
  485. name
  486. }));
  487. /**
  488. * A component that renders all plugin fills in a hidden div.
  489. *
  490. * @param props
  491. * @param props.scope
  492. * @param props.onError
  493. * @example
  494. * ```js
  495. * // Using ES5 syntax
  496. * var el = wp.element.createElement;
  497. * var PluginArea = wp.plugins.PluginArea;
  498. *
  499. * function Layout() {
  500. * return el(
  501. * 'div',
  502. * { scope: 'my-page' },
  503. * 'Content of the page',
  504. * PluginArea
  505. * );
  506. * }
  507. * ```
  508. *
  509. * @example
  510. * ```js
  511. * // Using ESNext syntax
  512. * import { PluginArea } from '@wordpress/plugins';
  513. *
  514. * const Layout = () => (
  515. * <div>
  516. * Content of the page
  517. * <PluginArea scope="my-page" />
  518. * </div>
  519. * );
  520. * ```
  521. *
  522. * @return {WPComponent} The component to be rendered.
  523. */
  524. function PluginArea({
  525. scope,
  526. onError
  527. }) {
  528. const store = (0,external_wp_element_namespaceObject.useMemo)(() => {
  529. let lastValue = [];
  530. return {
  531. subscribe(listener) {
  532. (0,external_wp_hooks_namespaceObject.addAction)('plugins.pluginRegistered', 'core/plugins/plugin-area/plugins-registered', listener);
  533. (0,external_wp_hooks_namespaceObject.addAction)('plugins.pluginUnregistered', 'core/plugins/plugin-area/plugins-unregistered', listener);
  534. return () => {
  535. (0,external_wp_hooks_namespaceObject.removeAction)('plugins.pluginRegistered', 'core/plugins/plugin-area/plugins-registered');
  536. (0,external_wp_hooks_namespaceObject.removeAction)('plugins.pluginUnregistered', 'core/plugins/plugin-area/plugins-unregistered');
  537. };
  538. },
  539. getValue() {
  540. const nextValue = getPlugins(scope);
  541. if (!external_wp_isShallowEqual_default()(lastValue, nextValue)) {
  542. lastValue = nextValue;
  543. }
  544. return lastValue;
  545. }
  546. };
  547. }, [scope]);
  548. const plugins = (0,external_wp_element_namespaceObject.useSyncExternalStore)(store.subscribe, store.getValue);
  549. return (0,external_wp_element_namespaceObject.createElement)("div", {
  550. style: {
  551. display: 'none'
  552. }
  553. }, plugins.map(({
  554. icon,
  555. name,
  556. render: Plugin
  557. }) => (0,external_wp_element_namespaceObject.createElement)(PluginContextProvider, {
  558. key: name,
  559. value: getPluginContext(icon, name)
  560. }, (0,external_wp_element_namespaceObject.createElement)(PluginErrorBoundary, {
  561. name: name,
  562. onError: onError
  563. }, (0,external_wp_element_namespaceObject.createElement)(Plugin, null)))));
  564. }
  565. /* harmony default export */ var plugin_area = (PluginArea);
  566. ;// CONCATENATED MODULE: ./node_modules/@wordpress/plugins/build-module/components/index.js
  567. ;// CONCATENATED MODULE: ./node_modules/@wordpress/plugins/build-module/index.js
  568. (window.wp = window.wp || {}).plugins = __webpack_exports__;
  569. /******/ })()
  570. ;