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.

2151 lines
76 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. store: function() { return /* reexport */ store; }
  54. });
  55. // NAMESPACE OBJECT: ./node_modules/@wordpress/block-directory/build-module/store/selectors.js
  56. var selectors_namespaceObject = {};
  57. __webpack_require__.r(selectors_namespaceObject);
  58. __webpack_require__.d(selectors_namespaceObject, {
  59. getDownloadableBlocks: function() { return getDownloadableBlocks; },
  60. getErrorNoticeForBlock: function() { return getErrorNoticeForBlock; },
  61. getErrorNotices: function() { return getErrorNotices; },
  62. getInstalledBlockTypes: function() { return getInstalledBlockTypes; },
  63. getNewBlockTypes: function() { return getNewBlockTypes; },
  64. getUnusedBlockTypes: function() { return getUnusedBlockTypes; },
  65. isInstalling: function() { return isInstalling; },
  66. isRequestingDownloadableBlocks: function() { return isRequestingDownloadableBlocks; }
  67. });
  68. // NAMESPACE OBJECT: ./node_modules/@wordpress/block-directory/build-module/store/actions.js
  69. var actions_namespaceObject = {};
  70. __webpack_require__.r(actions_namespaceObject);
  71. __webpack_require__.d(actions_namespaceObject, {
  72. addInstalledBlockType: function() { return addInstalledBlockType; },
  73. clearErrorNotice: function() { return clearErrorNotice; },
  74. fetchDownloadableBlocks: function() { return fetchDownloadableBlocks; },
  75. installBlockType: function() { return installBlockType; },
  76. receiveDownloadableBlocks: function() { return receiveDownloadableBlocks; },
  77. removeInstalledBlockType: function() { return removeInstalledBlockType; },
  78. setErrorNotice: function() { return setErrorNotice; },
  79. setIsInstalling: function() { return setIsInstalling; },
  80. uninstallBlockType: function() { return uninstallBlockType; }
  81. });
  82. // NAMESPACE OBJECT: ./node_modules/@wordpress/block-directory/build-module/store/resolvers.js
  83. var resolvers_namespaceObject = {};
  84. __webpack_require__.r(resolvers_namespaceObject);
  85. __webpack_require__.d(resolvers_namespaceObject, {
  86. getDownloadableBlocks: function() { return resolvers_getDownloadableBlocks; }
  87. });
  88. ;// CONCATENATED MODULE: external ["wp","element"]
  89. var external_wp_element_namespaceObject = window["wp"]["element"];
  90. ;// CONCATENATED MODULE: external ["wp","plugins"]
  91. var external_wp_plugins_namespaceObject = window["wp"]["plugins"];
  92. ;// CONCATENATED MODULE: external ["wp","hooks"]
  93. var external_wp_hooks_namespaceObject = window["wp"]["hooks"];
  94. ;// CONCATENATED MODULE: external ["wp","blocks"]
  95. var external_wp_blocks_namespaceObject = window["wp"]["blocks"];
  96. ;// CONCATENATED MODULE: external ["wp","data"]
  97. var external_wp_data_namespaceObject = window["wp"]["data"];
  98. ;// CONCATENATED MODULE: external ["wp","editor"]
  99. var external_wp_editor_namespaceObject = window["wp"]["editor"];
  100. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-directory/build-module/store/reducer.js
  101. /**
  102. * WordPress dependencies
  103. */
  104. /**
  105. * Reducer returning an array of downloadable blocks.
  106. *
  107. * @param {Object} state Current state.
  108. * @param {Object} action Dispatched action.
  109. *
  110. * @return {Object} Updated state.
  111. */
  112. const downloadableBlocks = (state = {}, action) => {
  113. switch (action.type) {
  114. case 'FETCH_DOWNLOADABLE_BLOCKS':
  115. return {
  116. ...state,
  117. [action.filterValue]: {
  118. isRequesting: true
  119. }
  120. };
  121. case 'RECEIVE_DOWNLOADABLE_BLOCKS':
  122. return {
  123. ...state,
  124. [action.filterValue]: {
  125. results: action.downloadableBlocks,
  126. isRequesting: false
  127. }
  128. };
  129. }
  130. return state;
  131. };
  132. /**
  133. * Reducer managing the installation and deletion of blocks.
  134. *
  135. * @param {Object} state Current state.
  136. * @param {Object} action Dispatched action.
  137. *
  138. * @return {Object} Updated state.
  139. */
  140. const blockManagement = (state = {
  141. installedBlockTypes: [],
  142. isInstalling: {}
  143. }, action) => {
  144. switch (action.type) {
  145. case 'ADD_INSTALLED_BLOCK_TYPE':
  146. return {
  147. ...state,
  148. installedBlockTypes: [...state.installedBlockTypes, action.item]
  149. };
  150. case 'REMOVE_INSTALLED_BLOCK_TYPE':
  151. return {
  152. ...state,
  153. installedBlockTypes: state.installedBlockTypes.filter(blockType => blockType.name !== action.item.name)
  154. };
  155. case 'SET_INSTALLING_BLOCK':
  156. return {
  157. ...state,
  158. isInstalling: {
  159. ...state.isInstalling,
  160. [action.blockId]: action.isInstalling
  161. }
  162. };
  163. }
  164. return state;
  165. };
  166. /**
  167. * Reducer returning an object of error notices.
  168. *
  169. * @param {Object} state Current state.
  170. * @param {Object} action Dispatched action.
  171. *
  172. * @return {Object} Updated state.
  173. */
  174. const errorNotices = (state = {}, action) => {
  175. switch (action.type) {
  176. case 'SET_ERROR_NOTICE':
  177. return {
  178. ...state,
  179. [action.blockId]: {
  180. message: action.message,
  181. isFatal: action.isFatal
  182. }
  183. };
  184. case 'CLEAR_ERROR_NOTICE':
  185. const {
  186. [action.blockId]: blockId,
  187. ...restState
  188. } = state;
  189. return restState;
  190. }
  191. return state;
  192. };
  193. /* harmony default export */ var reducer = ((0,external_wp_data_namespaceObject.combineReducers)({
  194. downloadableBlocks,
  195. blockManagement,
  196. errorNotices
  197. }));
  198. ;// CONCATENATED MODULE: external ["wp","blockEditor"]
  199. var external_wp_blockEditor_namespaceObject = window["wp"]["blockEditor"];
  200. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-directory/build-module/store/utils/has-block-type.js
  201. /**
  202. * Check if a block list contains a specific block type. Recursively searches
  203. * through `innerBlocks` if they exist.
  204. *
  205. * @param {Object} blockType A block object to search for.
  206. * @param {Object[]} blocks The list of blocks to look through.
  207. *
  208. * @return {boolean} Whether the blockType is found.
  209. */
  210. function hasBlockType(blockType, blocks = []) {
  211. if (!blocks.length) {
  212. return false;
  213. }
  214. if (blocks.some(({
  215. name
  216. }) => name === blockType.name)) {
  217. return true;
  218. }
  219. for (let i = 0; i < blocks.length; i++) {
  220. if (hasBlockType(blockType, blocks[i].innerBlocks)) {
  221. return true;
  222. }
  223. }
  224. return false;
  225. }
  226. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-directory/build-module/store/selectors.js
  227. /**
  228. * WordPress dependencies
  229. */
  230. /**
  231. * Internal dependencies
  232. */
  233. /**
  234. * Returns true if application is requesting for downloadable blocks.
  235. *
  236. * @param {Object} state Global application state.
  237. * @param {string} filterValue Search string.
  238. *
  239. * @return {boolean} Whether a request is in progress for the blocks list.
  240. */
  241. function isRequestingDownloadableBlocks(state, filterValue) {
  242. var _state$downloadableBl;
  243. return (_state$downloadableBl = state.downloadableBlocks[filterValue]?.isRequesting) !== null && _state$downloadableBl !== void 0 ? _state$downloadableBl : false;
  244. }
  245. /**
  246. * Returns the available uninstalled blocks.
  247. *
  248. * @param {Object} state Global application state.
  249. * @param {string} filterValue Search string.
  250. *
  251. * @return {Array} Downloadable blocks.
  252. */
  253. function getDownloadableBlocks(state, filterValue) {
  254. var _state$downloadableBl2;
  255. return (_state$downloadableBl2 = state.downloadableBlocks[filterValue]?.results) !== null && _state$downloadableBl2 !== void 0 ? _state$downloadableBl2 : [];
  256. }
  257. /**
  258. * Returns the block types that have been installed on the server in this
  259. * session.
  260. *
  261. * @param {Object} state Global application state.
  262. *
  263. * @return {Array} Block type items
  264. */
  265. function getInstalledBlockTypes(state) {
  266. return state.blockManagement.installedBlockTypes;
  267. }
  268. /**
  269. * Returns block types that have been installed on the server and used in the
  270. * current post.
  271. *
  272. * @param {Object} state Global application state.
  273. *
  274. * @return {Array} Block type items.
  275. */
  276. const getNewBlockTypes = (0,external_wp_data_namespaceObject.createRegistrySelector)(select => state => {
  277. const usedBlockTree = select(external_wp_blockEditor_namespaceObject.store).getBlocks();
  278. const installedBlockTypes = getInstalledBlockTypes(state);
  279. return installedBlockTypes.filter(blockType => hasBlockType(blockType, usedBlockTree));
  280. });
  281. /**
  282. * Returns the block types that have been installed on the server but are not
  283. * used in the current post.
  284. *
  285. * @param {Object} state Global application state.
  286. *
  287. * @return {Array} Block type items.
  288. */
  289. const getUnusedBlockTypes = (0,external_wp_data_namespaceObject.createRegistrySelector)(select => state => {
  290. const usedBlockTree = select(external_wp_blockEditor_namespaceObject.store).getBlocks();
  291. const installedBlockTypes = getInstalledBlockTypes(state);
  292. return installedBlockTypes.filter(blockType => !hasBlockType(blockType, usedBlockTree));
  293. });
  294. /**
  295. * Returns true if a block plugin install is in progress.
  296. *
  297. * @param {Object} state Global application state.
  298. * @param {string} blockId Id of the block.
  299. *
  300. * @return {boolean} Whether this block is currently being installed.
  301. */
  302. function isInstalling(state, blockId) {
  303. return state.blockManagement.isInstalling[blockId] || false;
  304. }
  305. /**
  306. * Returns all block error notices.
  307. *
  308. * @param {Object} state Global application state.
  309. *
  310. * @return {Object} Object with error notices.
  311. */
  312. function getErrorNotices(state) {
  313. return state.errorNotices;
  314. }
  315. /**
  316. * Returns the error notice for a given block.
  317. *
  318. * @param {Object} state Global application state.
  319. * @param {string} blockId The ID of the block plugin. eg: my-block
  320. *
  321. * @return {string|boolean} The error text, or false if no error.
  322. */
  323. function getErrorNoticeForBlock(state, blockId) {
  324. return state.errorNotices[blockId];
  325. }
  326. ;// CONCATENATED MODULE: external ["wp","i18n"]
  327. var external_wp_i18n_namespaceObject = window["wp"]["i18n"];
  328. ;// CONCATENATED MODULE: external ["wp","apiFetch"]
  329. var external_wp_apiFetch_namespaceObject = window["wp"]["apiFetch"];
  330. var external_wp_apiFetch_default = /*#__PURE__*/__webpack_require__.n(external_wp_apiFetch_namespaceObject);
  331. ;// CONCATENATED MODULE: external ["wp","notices"]
  332. var external_wp_notices_namespaceObject = window["wp"]["notices"];
  333. ;// CONCATENATED MODULE: external ["wp","url"]
  334. var external_wp_url_namespaceObject = window["wp"]["url"];
  335. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-directory/build-module/store/load-assets.js
  336. /**
  337. * WordPress dependencies
  338. */
  339. /**
  340. * Load an asset for a block.
  341. *
  342. * This function returns a Promise that will resolve once the asset is loaded,
  343. * or in the case of Stylesheets and Inline JavaScript, will resolve immediately.
  344. *
  345. * @param {HTMLElement} el A HTML Element asset to inject.
  346. *
  347. * @return {Promise} Promise which will resolve when the asset is loaded.
  348. */
  349. const loadAsset = el => {
  350. return new Promise((resolve, reject) => {
  351. /*
  352. * Reconstruct the passed element, this is required as inserting the Node directly
  353. * won't always fire the required onload events, even if the asset wasn't already loaded.
  354. */
  355. const newNode = document.createElement(el.nodeName);
  356. ['id', 'rel', 'src', 'href', 'type'].forEach(attr => {
  357. if (el[attr]) {
  358. newNode[attr] = el[attr];
  359. }
  360. });
  361. // Append inline <script> contents.
  362. if (el.innerHTML) {
  363. newNode.appendChild(document.createTextNode(el.innerHTML));
  364. }
  365. newNode.onload = () => resolve(true);
  366. newNode.onerror = () => reject(new Error('Error loading asset.'));
  367. document.body.appendChild(newNode);
  368. // Resolve Stylesheets and Inline JavaScript immediately.
  369. if ('link' === newNode.nodeName.toLowerCase() || 'script' === newNode.nodeName.toLowerCase() && !newNode.src) {
  370. resolve();
  371. }
  372. });
  373. };
  374. /**
  375. * Load the asset files for a block
  376. */
  377. async function loadAssets() {
  378. /*
  379. * Fetch the current URL (post-new.php, or post.php?post=1&action=edit) and compare the
  380. * JavaScript and CSS assets loaded between the pages. This imports the required assets
  381. * for the block into the current page while not requiring that we know them up-front.
  382. * In the future this can be improved by reliance upon block.json and/or a script-loader
  383. * dependency API.
  384. */
  385. const response = await external_wp_apiFetch_default()({
  386. url: document.location.href,
  387. parse: false
  388. });
  389. const data = await response.text();
  390. const doc = new window.DOMParser().parseFromString(data, 'text/html');
  391. const newAssets = Array.from(doc.querySelectorAll('link[rel="stylesheet"],script')).filter(asset => asset.id && !document.getElementById(asset.id));
  392. /*
  393. * Load each asset in order, as they may depend upon an earlier loaded script.
  394. * Stylesheets and Inline Scripts will resolve immediately upon insertion.
  395. */
  396. for (const newAsset of newAssets) {
  397. await loadAsset(newAsset);
  398. }
  399. }
  400. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-directory/build-module/store/utils/get-plugin-url.js
  401. /**
  402. * Get the plugin's direct API link out of a block-directory response.
  403. *
  404. * @param {Object} block The block object
  405. *
  406. * @return {string} The plugin URL, if exists.
  407. */
  408. function getPluginUrl(block) {
  409. if (!block) {
  410. return false;
  411. }
  412. const link = block.links['wp:plugin'] || block.links.self;
  413. if (link && link.length) {
  414. return link[0].href;
  415. }
  416. return false;
  417. }
  418. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-directory/build-module/store/actions.js
  419. /**
  420. * WordPress dependencies
  421. */
  422. /**
  423. * Internal dependencies
  424. */
  425. /**
  426. * Returns an action object used in signalling that the downloadable blocks
  427. * have been requested and are loading.
  428. *
  429. * @param {string} filterValue Search string.
  430. *
  431. * @return {Object} Action object.
  432. */
  433. function fetchDownloadableBlocks(filterValue) {
  434. return {
  435. type: 'FETCH_DOWNLOADABLE_BLOCKS',
  436. filterValue
  437. };
  438. }
  439. /**
  440. * Returns an action object used in signalling that the downloadable blocks
  441. * have been updated.
  442. *
  443. * @param {Array} downloadableBlocks Downloadable blocks.
  444. * @param {string} filterValue Search string.
  445. *
  446. * @return {Object} Action object.
  447. */
  448. function receiveDownloadableBlocks(downloadableBlocks, filterValue) {
  449. return {
  450. type: 'RECEIVE_DOWNLOADABLE_BLOCKS',
  451. downloadableBlocks,
  452. filterValue
  453. };
  454. }
  455. /**
  456. * Action triggered to install a block plugin.
  457. *
  458. * @param {Object} block The block item returned by search.
  459. *
  460. * @return {boolean} Whether the block was successfully installed & loaded.
  461. */
  462. const installBlockType = block => async ({
  463. registry,
  464. dispatch
  465. }) => {
  466. const {
  467. id,
  468. name
  469. } = block;
  470. let success = false;
  471. dispatch.clearErrorNotice(id);
  472. try {
  473. dispatch.setIsInstalling(id, true);
  474. // If we have a wp:plugin link, the plugin is installed but inactive.
  475. const url = getPluginUrl(block);
  476. let links = {};
  477. if (url) {
  478. await external_wp_apiFetch_default()({
  479. method: 'PUT',
  480. url,
  481. data: {
  482. status: 'active'
  483. }
  484. });
  485. } else {
  486. const response = await external_wp_apiFetch_default()({
  487. method: 'POST',
  488. path: 'wp/v2/plugins',
  489. data: {
  490. slug: id,
  491. status: 'active'
  492. }
  493. });
  494. // Add the `self` link for newly-installed blocks.
  495. links = response._links;
  496. }
  497. dispatch.addInstalledBlockType({
  498. ...block,
  499. links: {
  500. ...block.links,
  501. ...links
  502. }
  503. });
  504. // Ensures that the block metadata is propagated to the editor when registered on the server.
  505. const metadataFields = ['api_version', 'title', 'category', 'parent', 'icon', 'description', 'keywords', 'attributes', 'provides_context', 'uses_context', 'supports', 'styles', 'example', 'variations'];
  506. await external_wp_apiFetch_default()({
  507. path: (0,external_wp_url_namespaceObject.addQueryArgs)(`/wp/v2/block-types/${name}`, {
  508. _fields: metadataFields
  509. })
  510. })
  511. // Ignore when the block is not registered on the server.
  512. .catch(() => {}).then(response => {
  513. if (!response) {
  514. return;
  515. }
  516. (0,external_wp_blocks_namespaceObject.unstable__bootstrapServerSideBlockDefinitions)({
  517. [name]: Object.fromEntries(Object.entries(response).filter(([key]) => metadataFields.includes(key)))
  518. });
  519. });
  520. await loadAssets();
  521. const registeredBlocks = registry.select(external_wp_blocks_namespaceObject.store).getBlockTypes();
  522. if (!registeredBlocks.some(i => i.name === name)) {
  523. throw new Error((0,external_wp_i18n_namespaceObject.__)('Error registering block. Try reloading the page.'));
  524. }
  525. registry.dispatch(external_wp_notices_namespaceObject.store).createInfoNotice((0,external_wp_i18n_namespaceObject.sprintf)(
  526. // translators: %s is the block title.
  527. (0,external_wp_i18n_namespaceObject.__)('Block %s installed and added.'), block.title), {
  528. speak: true,
  529. type: 'snackbar'
  530. });
  531. success = true;
  532. } catch (error) {
  533. let message = error.message || (0,external_wp_i18n_namespaceObject.__)('An error occurred.');
  534. // Errors we throw are fatal.
  535. let isFatal = error instanceof Error;
  536. // Specific API errors that are fatal.
  537. const fatalAPIErrors = {
  538. folder_exists: (0,external_wp_i18n_namespaceObject.__)('This block is already installed. Try reloading the page.'),
  539. unable_to_connect_to_filesystem: (0,external_wp_i18n_namespaceObject.__)('Error installing block. You can reload the page and try again.')
  540. };
  541. if (fatalAPIErrors[error.code]) {
  542. isFatal = true;
  543. message = fatalAPIErrors[error.code];
  544. }
  545. dispatch.setErrorNotice(id, message, isFatal);
  546. registry.dispatch(external_wp_notices_namespaceObject.store).createErrorNotice(message, {
  547. speak: true,
  548. isDismissible: true
  549. });
  550. }
  551. dispatch.setIsInstalling(id, false);
  552. return success;
  553. };
  554. /**
  555. * Action triggered to uninstall a block plugin.
  556. *
  557. * @param {Object} block The blockType object.
  558. */
  559. const uninstallBlockType = block => async ({
  560. registry,
  561. dispatch
  562. }) => {
  563. try {
  564. const url = getPluginUrl(block);
  565. await external_wp_apiFetch_default()({
  566. method: 'PUT',
  567. url,
  568. data: {
  569. status: 'inactive'
  570. }
  571. });
  572. await external_wp_apiFetch_default()({
  573. method: 'DELETE',
  574. url
  575. });
  576. dispatch.removeInstalledBlockType(block);
  577. } catch (error) {
  578. registry.dispatch(external_wp_notices_namespaceObject.store).createErrorNotice(error.message || (0,external_wp_i18n_namespaceObject.__)('An error occurred.'));
  579. }
  580. };
  581. /**
  582. * Returns an action object used to add a block type to the "newly installed"
  583. * tracking list.
  584. *
  585. * @param {Object} item The block item with the block id and name.
  586. *
  587. * @return {Object} Action object.
  588. */
  589. function addInstalledBlockType(item) {
  590. return {
  591. type: 'ADD_INSTALLED_BLOCK_TYPE',
  592. item
  593. };
  594. }
  595. /**
  596. * Returns an action object used to remove a block type from the "newly installed"
  597. * tracking list.
  598. *
  599. * @param {string} item The block item with the block id and name.
  600. *
  601. * @return {Object} Action object.
  602. */
  603. function removeInstalledBlockType(item) {
  604. return {
  605. type: 'REMOVE_INSTALLED_BLOCK_TYPE',
  606. item
  607. };
  608. }
  609. /**
  610. * Returns an action object used to indicate install in progress.
  611. *
  612. * @param {string} blockId
  613. * @param {boolean} isInstalling
  614. *
  615. * @return {Object} Action object.
  616. */
  617. function setIsInstalling(blockId, isInstalling) {
  618. return {
  619. type: 'SET_INSTALLING_BLOCK',
  620. blockId,
  621. isInstalling
  622. };
  623. }
  624. /**
  625. * Sets an error notice to be displayed to the user for a given block.
  626. *
  627. * @param {string} blockId The ID of the block plugin. eg: my-block
  628. * @param {string} message The message shown in the notice.
  629. * @param {boolean} isFatal Whether the user can recover from the error.
  630. *
  631. * @return {Object} Action object.
  632. */
  633. function setErrorNotice(blockId, message, isFatal = false) {
  634. return {
  635. type: 'SET_ERROR_NOTICE',
  636. blockId,
  637. message,
  638. isFatal
  639. };
  640. }
  641. /**
  642. * Sets the error notice to empty for specific block.
  643. *
  644. * @param {string} blockId The ID of the block plugin. eg: my-block
  645. *
  646. * @return {Object} Action object.
  647. */
  648. function clearErrorNotice(blockId) {
  649. return {
  650. type: 'CLEAR_ERROR_NOTICE',
  651. blockId
  652. };
  653. }
  654. ;// CONCATENATED MODULE: ./node_modules/tslib/tslib.es6.mjs
  655. /******************************************************************************
  656. Copyright (c) Microsoft Corporation.
  657. Permission to use, copy, modify, and/or distribute this software for any
  658. purpose with or without fee is hereby granted.
  659. THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
  660. REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
  661. AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
  662. INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
  663. LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
  664. OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  665. PERFORMANCE OF THIS SOFTWARE.
  666. ***************************************************************************** */
  667. /* global Reflect, Promise, SuppressedError, Symbol */
  668. var extendStatics = function(d, b) {
  669. extendStatics = Object.setPrototypeOf ||
  670. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  671. function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
  672. return extendStatics(d, b);
  673. };
  674. function __extends(d, b) {
  675. if (typeof b !== "function" && b !== null)
  676. throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
  677. extendStatics(d, b);
  678. function __() { this.constructor = d; }
  679. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  680. }
  681. var __assign = function() {
  682. __assign = Object.assign || function __assign(t) {
  683. for (var s, i = 1, n = arguments.length; i < n; i++) {
  684. s = arguments[i];
  685. for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
  686. }
  687. return t;
  688. }
  689. return __assign.apply(this, arguments);
  690. }
  691. function __rest(s, e) {
  692. var t = {};
  693. for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
  694. t[p] = s[p];
  695. if (s != null && typeof Object.getOwnPropertySymbols === "function")
  696. for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
  697. if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
  698. t[p[i]] = s[p[i]];
  699. }
  700. return t;
  701. }
  702. function __decorate(decorators, target, key, desc) {
  703. var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  704. if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  705. else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
  706. return c > 3 && r && Object.defineProperty(target, key, r), r;
  707. }
  708. function __param(paramIndex, decorator) {
  709. return function (target, key) { decorator(target, key, paramIndex); }
  710. }
  711. function __esDecorate(ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) {
  712. function accept(f) { if (f !== void 0 && typeof f !== "function") throw new TypeError("Function expected"); return f; }
  713. var kind = contextIn.kind, key = kind === "getter" ? "get" : kind === "setter" ? "set" : "value";
  714. var target = !descriptorIn && ctor ? contextIn["static"] ? ctor : ctor.prototype : null;
  715. var descriptor = descriptorIn || (target ? Object.getOwnPropertyDescriptor(target, contextIn.name) : {});
  716. var _, done = false;
  717. for (var i = decorators.length - 1; i >= 0; i--) {
  718. var context = {};
  719. for (var p in contextIn) context[p] = p === "access" ? {} : contextIn[p];
  720. for (var p in contextIn.access) context.access[p] = contextIn.access[p];
  721. context.addInitializer = function (f) { if (done) throw new TypeError("Cannot add initializers after decoration has completed"); extraInitializers.push(accept(f || null)); };
  722. var result = (0, decorators[i])(kind === "accessor" ? { get: descriptor.get, set: descriptor.set } : descriptor[key], context);
  723. if (kind === "accessor") {
  724. if (result === void 0) continue;
  725. if (result === null || typeof result !== "object") throw new TypeError("Object expected");
  726. if (_ = accept(result.get)) descriptor.get = _;
  727. if (_ = accept(result.set)) descriptor.set = _;
  728. if (_ = accept(result.init)) initializers.unshift(_);
  729. }
  730. else if (_ = accept(result)) {
  731. if (kind === "field") initializers.unshift(_);
  732. else descriptor[key] = _;
  733. }
  734. }
  735. if (target) Object.defineProperty(target, contextIn.name, descriptor);
  736. done = true;
  737. };
  738. function __runInitializers(thisArg, initializers, value) {
  739. var useValue = arguments.length > 2;
  740. for (var i = 0; i < initializers.length; i++) {
  741. value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg);
  742. }
  743. return useValue ? value : void 0;
  744. };
  745. function __propKey(x) {
  746. return typeof x === "symbol" ? x : "".concat(x);
  747. };
  748. function __setFunctionName(f, name, prefix) {
  749. if (typeof name === "symbol") name = name.description ? "[".concat(name.description, "]") : "";
  750. return Object.defineProperty(f, "name", { configurable: true, value: prefix ? "".concat(prefix, " ", name) : name });
  751. };
  752. function __metadata(metadataKey, metadataValue) {
  753. if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(metadataKey, metadataValue);
  754. }
  755. function __awaiter(thisArg, _arguments, P, generator) {
  756. function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
  757. return new (P || (P = Promise))(function (resolve, reject) {
  758. function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
  759. function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
  760. function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
  761. step((generator = generator.apply(thisArg, _arguments || [])).next());
  762. });
  763. }
  764. function __generator(thisArg, body) {
  765. var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
  766. return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
  767. function verb(n) { return function (v) { return step([n, v]); }; }
  768. function step(op) {
  769. if (f) throw new TypeError("Generator is already executing.");
  770. while (g && (g = 0, op[0] && (_ = 0)), _) try {
  771. if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
  772. if (y = 0, t) op = [op[0] & 2, t.value];
  773. switch (op[0]) {
  774. case 0: case 1: t = op; break;
  775. case 4: _.label++; return { value: op[1], done: false };
  776. case 5: _.label++; y = op[1]; op = [0]; continue;
  777. case 7: op = _.ops.pop(); _.trys.pop(); continue;
  778. default:
  779. if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
  780. if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
  781. if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
  782. if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
  783. if (t[2]) _.ops.pop();
  784. _.trys.pop(); continue;
  785. }
  786. op = body.call(thisArg, _);
  787. } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
  788. if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
  789. }
  790. }
  791. var __createBinding = Object.create ? (function(o, m, k, k2) {
  792. if (k2 === undefined) k2 = k;
  793. var desc = Object.getOwnPropertyDescriptor(m, k);
  794. if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
  795. desc = { enumerable: true, get: function() { return m[k]; } };
  796. }
  797. Object.defineProperty(o, k2, desc);
  798. }) : (function(o, m, k, k2) {
  799. if (k2 === undefined) k2 = k;
  800. o[k2] = m[k];
  801. });
  802. function __exportStar(m, o) {
  803. for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(o, p)) __createBinding(o, m, p);
  804. }
  805. function __values(o) {
  806. var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
  807. if (m) return m.call(o);
  808. if (o && typeof o.length === "number") return {
  809. next: function () {
  810. if (o && i >= o.length) o = void 0;
  811. return { value: o && o[i++], done: !o };
  812. }
  813. };
  814. throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
  815. }
  816. function __read(o, n) {
  817. var m = typeof Symbol === "function" && o[Symbol.iterator];
  818. if (!m) return o;
  819. var i = m.call(o), r, ar = [], e;
  820. try {
  821. while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
  822. }
  823. catch (error) { e = { error: error }; }
  824. finally {
  825. try {
  826. if (r && !r.done && (m = i["return"])) m.call(i);
  827. }
  828. finally { if (e) throw e.error; }
  829. }
  830. return ar;
  831. }
  832. /** @deprecated */
  833. function __spread() {
  834. for (var ar = [], i = 0; i < arguments.length; i++)
  835. ar = ar.concat(__read(arguments[i]));
  836. return ar;
  837. }
  838. /** @deprecated */
  839. function __spreadArrays() {
  840. for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;
  841. for (var r = Array(s), k = 0, i = 0; i < il; i++)
  842. for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
  843. r[k] = a[j];
  844. return r;
  845. }
  846. function __spreadArray(to, from, pack) {
  847. if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
  848. if (ar || !(i in from)) {
  849. if (!ar) ar = Array.prototype.slice.call(from, 0, i);
  850. ar[i] = from[i];
  851. }
  852. }
  853. return to.concat(ar || Array.prototype.slice.call(from));
  854. }
  855. function __await(v) {
  856. return this instanceof __await ? (this.v = v, this) : new __await(v);
  857. }
  858. function __asyncGenerator(thisArg, _arguments, generator) {
  859. if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
  860. var g = generator.apply(thisArg, _arguments || []), i, q = [];
  861. return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i;
  862. function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }
  863. function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }
  864. function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }
  865. function fulfill(value) { resume("next", value); }
  866. function reject(value) { resume("throw", value); }
  867. function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }
  868. }
  869. function __asyncDelegator(o) {
  870. var i, p;
  871. return i = {}, verb("next"), verb("throw", function (e) { throw e; }), verb("return"), i[Symbol.iterator] = function () { return this; }, i;
  872. function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: false } : f ? f(v) : v; } : f; }
  873. }
  874. function __asyncValues(o) {
  875. if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
  876. var m = o[Symbol.asyncIterator], i;
  877. return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i);
  878. function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }
  879. function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }
  880. }
  881. function __makeTemplateObject(cooked, raw) {
  882. if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
  883. return cooked;
  884. };
  885. var __setModuleDefault = Object.create ? (function(o, v) {
  886. Object.defineProperty(o, "default", { enumerable: true, value: v });
  887. }) : function(o, v) {
  888. o["default"] = v;
  889. };
  890. function __importStar(mod) {
  891. if (mod && mod.__esModule) return mod;
  892. var result = {};
  893. if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
  894. __setModuleDefault(result, mod);
  895. return result;
  896. }
  897. function __importDefault(mod) {
  898. return (mod && mod.__esModule) ? mod : { default: mod };
  899. }
  900. function __classPrivateFieldGet(receiver, state, kind, f) {
  901. if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
  902. if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
  903. return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
  904. }
  905. function __classPrivateFieldSet(receiver, state, value, kind, f) {
  906. if (kind === "m") throw new TypeError("Private method is not writable");
  907. if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
  908. if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
  909. return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
  910. }
  911. function __classPrivateFieldIn(state, receiver) {
  912. if (receiver === null || (typeof receiver !== "object" && typeof receiver !== "function")) throw new TypeError("Cannot use 'in' operator on non-object");
  913. return typeof state === "function" ? receiver === state : state.has(receiver);
  914. }
  915. function __addDisposableResource(env, value, async) {
  916. if (value !== null && value !== void 0) {
  917. if (typeof value !== "object" && typeof value !== "function") throw new TypeError("Object expected.");
  918. var dispose;
  919. if (async) {
  920. if (!Symbol.asyncDispose) throw new TypeError("Symbol.asyncDispose is not defined.");
  921. dispose = value[Symbol.asyncDispose];
  922. }
  923. if (dispose === void 0) {
  924. if (!Symbol.dispose) throw new TypeError("Symbol.dispose is not defined.");
  925. dispose = value[Symbol.dispose];
  926. }
  927. if (typeof dispose !== "function") throw new TypeError("Object not disposable.");
  928. env.stack.push({ value: value, dispose: dispose, async: async });
  929. }
  930. else if (async) {
  931. env.stack.push({ async: true });
  932. }
  933. return value;
  934. }
  935. var _SuppressedError = typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
  936. var e = new Error(message);
  937. return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
  938. };
  939. function __disposeResources(env) {
  940. function fail(e) {
  941. env.error = env.hasError ? new _SuppressedError(e, env.error, "An error was suppressed during disposal.") : e;
  942. env.hasError = true;
  943. }
  944. function next() {
  945. while (env.stack.length) {
  946. var rec = env.stack.pop();
  947. try {
  948. var result = rec.dispose && rec.dispose.call(rec.value);
  949. if (rec.async) return Promise.resolve(result).then(next, function(e) { fail(e); return next(); });
  950. }
  951. catch (e) {
  952. fail(e);
  953. }
  954. }
  955. if (env.hasError) throw env.error;
  956. }
  957. return next();
  958. }
  959. /* harmony default export */ var tslib_es6 = ({
  960. __extends,
  961. __assign,
  962. __rest,
  963. __decorate,
  964. __param,
  965. __metadata,
  966. __awaiter,
  967. __generator,
  968. __createBinding,
  969. __exportStar,
  970. __values,
  971. __read,
  972. __spread,
  973. __spreadArrays,
  974. __spreadArray,
  975. __await,
  976. __asyncGenerator,
  977. __asyncDelegator,
  978. __asyncValues,
  979. __makeTemplateObject,
  980. __importStar,
  981. __importDefault,
  982. __classPrivateFieldGet,
  983. __classPrivateFieldSet,
  984. __classPrivateFieldIn,
  985. __addDisposableResource,
  986. __disposeResources,
  987. });
  988. ;// CONCATENATED MODULE: ./node_modules/lower-case/dist.es2015/index.js
  989. /**
  990. * Source: ftp://ftp.unicode.org/Public/UCD/latest/ucd/SpecialCasing.txt
  991. */
  992. var SUPPORTED_LOCALE = {
  993. tr: {
  994. regexp: /\u0130|\u0049|\u0049\u0307/g,
  995. map: {
  996. İ: "\u0069",
  997. I: "\u0131",
  998. : "\u0069",
  999. },
  1000. },
  1001. az: {
  1002. regexp: /\u0130/g,
  1003. map: {
  1004. İ: "\u0069",
  1005. I: "\u0131",
  1006. : "\u0069",
  1007. },
  1008. },
  1009. lt: {
  1010. regexp: /\u0049|\u004A|\u012E|\u00CC|\u00CD|\u0128/g,
  1011. map: {
  1012. I: "\u0069\u0307",
  1013. J: "\u006A\u0307",
  1014. Į: "\u012F\u0307",
  1015. Ì: "\u0069\u0307\u0300",
  1016. Í: "\u0069\u0307\u0301",
  1017. Ĩ: "\u0069\u0307\u0303",
  1018. },
  1019. },
  1020. };
  1021. /**
  1022. * Localized lower case.
  1023. */
  1024. function localeLowerCase(str, locale) {
  1025. var lang = SUPPORTED_LOCALE[locale.toLowerCase()];
  1026. if (lang)
  1027. return lowerCase(str.replace(lang.regexp, function (m) { return lang.map[m]; }));
  1028. return lowerCase(str);
  1029. }
  1030. /**
  1031. * Lower case as a function.
  1032. */
  1033. function lowerCase(str) {
  1034. return str.toLowerCase();
  1035. }
  1036. ;// CONCATENATED MODULE: ./node_modules/no-case/dist.es2015/index.js
  1037. // Support camel case ("camelCase" -> "camel Case" and "CAMELCase" -> "CAMEL Case").
  1038. var DEFAULT_SPLIT_REGEXP = [/([a-z0-9])([A-Z])/g, /([A-Z])([A-Z][a-z])/g];
  1039. // Remove all non-word characters.
  1040. var DEFAULT_STRIP_REGEXP = /[^A-Z0-9]+/gi;
  1041. /**
  1042. * Normalize the string into something other libraries can manipulate easier.
  1043. */
  1044. function noCase(input, options) {
  1045. if (options === void 0) { options = {}; }
  1046. var _a = options.splitRegexp, splitRegexp = _a === void 0 ? DEFAULT_SPLIT_REGEXP : _a, _b = options.stripRegexp, stripRegexp = _b === void 0 ? DEFAULT_STRIP_REGEXP : _b, _c = options.transform, transform = _c === void 0 ? lowerCase : _c, _d = options.delimiter, delimiter = _d === void 0 ? " " : _d;
  1047. var result = replace(replace(input, splitRegexp, "$1\0$2"), stripRegexp, "\0");
  1048. var start = 0;
  1049. var end = result.length;
  1050. // Trim the delimiter from around the output string.
  1051. while (result.charAt(start) === "\0")
  1052. start++;
  1053. while (result.charAt(end - 1) === "\0")
  1054. end--;
  1055. // Transform each token independently.
  1056. return result.slice(start, end).split("\0").map(transform).join(delimiter);
  1057. }
  1058. /**
  1059. * Replace `re` in the input string with the replacement value.
  1060. */
  1061. function replace(input, re, value) {
  1062. if (re instanceof RegExp)
  1063. return input.replace(re, value);
  1064. return re.reduce(function (input, re) { return input.replace(re, value); }, input);
  1065. }
  1066. ;// CONCATENATED MODULE: ./node_modules/pascal-case/dist.es2015/index.js
  1067. function pascalCaseTransform(input, index) {
  1068. var firstChar = input.charAt(0);
  1069. var lowerChars = input.substr(1).toLowerCase();
  1070. if (index > 0 && firstChar >= "0" && firstChar <= "9") {
  1071. return "_" + firstChar + lowerChars;
  1072. }
  1073. return "" + firstChar.toUpperCase() + lowerChars;
  1074. }
  1075. function dist_es2015_pascalCaseTransformMerge(input) {
  1076. return input.charAt(0).toUpperCase() + input.slice(1).toLowerCase();
  1077. }
  1078. function pascalCase(input, options) {
  1079. if (options === void 0) { options = {}; }
  1080. return noCase(input, __assign({ delimiter: "", transform: pascalCaseTransform }, options));
  1081. }
  1082. ;// CONCATENATED MODULE: ./node_modules/camel-case/dist.es2015/index.js
  1083. function camelCaseTransform(input, index) {
  1084. if (index === 0)
  1085. return input.toLowerCase();
  1086. return pascalCaseTransform(input, index);
  1087. }
  1088. function camelCaseTransformMerge(input, index) {
  1089. if (index === 0)
  1090. return input.toLowerCase();
  1091. return pascalCaseTransformMerge(input);
  1092. }
  1093. function camelCase(input, options) {
  1094. if (options === void 0) { options = {}; }
  1095. return pascalCase(input, __assign({ transform: camelCaseTransform }, options));
  1096. }
  1097. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-directory/build-module/store/resolvers.js
  1098. /**
  1099. * External dependencies
  1100. */
  1101. /**
  1102. * WordPress dependencies
  1103. */
  1104. /**
  1105. * Internal dependencies
  1106. */
  1107. const resolvers_getDownloadableBlocks = filterValue => async ({
  1108. dispatch
  1109. }) => {
  1110. if (!filterValue) {
  1111. return;
  1112. }
  1113. try {
  1114. dispatch(fetchDownloadableBlocks(filterValue));
  1115. const results = await external_wp_apiFetch_default()({
  1116. path: `wp/v2/block-directory/search?term=${filterValue}`
  1117. });
  1118. const blocks = results.map(result => Object.fromEntries(Object.entries(result).map(([key, value]) => [camelCase(key), value])));
  1119. dispatch(receiveDownloadableBlocks(blocks, filterValue));
  1120. } catch {}
  1121. };
  1122. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-directory/build-module/store/index.js
  1123. /**
  1124. * WordPress dependencies
  1125. */
  1126. /**
  1127. * Internal dependencies
  1128. */
  1129. /**
  1130. * Module Constants
  1131. */
  1132. const STORE_NAME = 'core/block-directory';
  1133. /**
  1134. * Block editor data store configuration.
  1135. *
  1136. * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/data/README.md#registerStore
  1137. *
  1138. * @type {Object}
  1139. */
  1140. const storeConfig = {
  1141. reducer: reducer,
  1142. selectors: selectors_namespaceObject,
  1143. actions: actions_namespaceObject,
  1144. resolvers: resolvers_namespaceObject
  1145. };
  1146. /**
  1147. * Store definition for the block directory namespace.
  1148. *
  1149. * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/data/README.md#createReduxStore
  1150. *
  1151. * @type {Object}
  1152. */
  1153. const store = (0,external_wp_data_namespaceObject.createReduxStore)(STORE_NAME, storeConfig);
  1154. (0,external_wp_data_namespaceObject.register)(store);
  1155. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-directory/build-module/components/auto-block-uninstaller/index.js
  1156. /**
  1157. * WordPress dependencies
  1158. */
  1159. /**
  1160. * Internal dependencies
  1161. */
  1162. function AutoBlockUninstaller() {
  1163. const {
  1164. uninstallBlockType
  1165. } = (0,external_wp_data_namespaceObject.useDispatch)(store);
  1166. const shouldRemoveBlockTypes = (0,external_wp_data_namespaceObject.useSelect)(select => {
  1167. const {
  1168. isAutosavingPost,
  1169. isSavingPost
  1170. } = select(external_wp_editor_namespaceObject.store);
  1171. return isSavingPost() && !isAutosavingPost();
  1172. }, []);
  1173. const unusedBlockTypes = (0,external_wp_data_namespaceObject.useSelect)(select => select(store).getUnusedBlockTypes(), []);
  1174. (0,external_wp_element_namespaceObject.useEffect)(() => {
  1175. if (shouldRemoveBlockTypes && unusedBlockTypes.length) {
  1176. unusedBlockTypes.forEach(blockType => {
  1177. uninstallBlockType(blockType);
  1178. (0,external_wp_blocks_namespaceObject.unregisterBlockType)(blockType.name);
  1179. });
  1180. }
  1181. }, [shouldRemoveBlockTypes]);
  1182. return null;
  1183. }
  1184. ;// CONCATENATED MODULE: external ["wp","compose"]
  1185. var external_wp_compose_namespaceObject = window["wp"]["compose"];
  1186. ;// CONCATENATED MODULE: external ["wp","components"]
  1187. var external_wp_components_namespaceObject = window["wp"]["components"];
  1188. ;// CONCATENATED MODULE: external ["wp","coreData"]
  1189. var external_wp_coreData_namespaceObject = window["wp"]["coreData"];
  1190. ;// CONCATENATED MODULE: external ["wp","htmlEntities"]
  1191. var external_wp_htmlEntities_namespaceObject = window["wp"]["htmlEntities"];
  1192. ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/icon/index.js
  1193. /**
  1194. * WordPress dependencies
  1195. */
  1196. /** @typedef {{icon: JSX.Element, size?: number} & import('@wordpress/primitives').SVGProps} IconProps */
  1197. /**
  1198. * Return an SVG icon.
  1199. *
  1200. * @param {IconProps} props icon is the SVG component to render
  1201. * size is a number specifiying the icon size in pixels
  1202. * Other props will be passed to wrapped SVG component
  1203. * @param {import('react').ForwardedRef<HTMLElement>} ref The forwarded ref to the SVG element.
  1204. *
  1205. * @return {JSX.Element} Icon component
  1206. */
  1207. function Icon({
  1208. icon,
  1209. size = 24,
  1210. ...props
  1211. }, ref) {
  1212. return (0,external_wp_element_namespaceObject.cloneElement)(icon, {
  1213. width: size,
  1214. height: size,
  1215. ...props,
  1216. ref
  1217. });
  1218. }
  1219. /* harmony default export */ var icon = ((0,external_wp_element_namespaceObject.forwardRef)(Icon));
  1220. ;// CONCATENATED MODULE: external ["wp","primitives"]
  1221. var external_wp_primitives_namespaceObject = window["wp"]["primitives"];
  1222. ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/star-filled.js
  1223. /**
  1224. * WordPress dependencies
  1225. */
  1226. const starFilled = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
  1227. xmlns: "http://www.w3.org/2000/svg",
  1228. viewBox: "0 0 24 24"
  1229. }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
  1230. d: "M11.776 4.454a.25.25 0 01.448 0l2.069 4.192a.25.25 0 00.188.137l4.626.672a.25.25 0 01.139.426l-3.348 3.263a.25.25 0 00-.072.222l.79 4.607a.25.25 0 01-.362.263l-4.138-2.175a.25.25 0 00-.232 0l-4.138 2.175a.25.25 0 01-.363-.263l.79-4.607a.25.25 0 00-.071-.222L4.754 9.881a.25.25 0 01.139-.426l4.626-.672a.25.25 0 00.188-.137l2.069-4.192z"
  1231. }));
  1232. /* harmony default export */ var star_filled = (starFilled);
  1233. ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/star-half.js
  1234. /**
  1235. * WordPress dependencies
  1236. */
  1237. const starHalf = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
  1238. xmlns: "http://www.w3.org/2000/svg",
  1239. viewBox: "0 0 24 24"
  1240. }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
  1241. d: "M9.518 8.783a.25.25 0 00.188-.137l2.069-4.192a.25.25 0 01.448 0l2.07 4.192a.25.25 0 00.187.137l4.626.672a.25.25 0 01.139.427l-3.347 3.262a.25.25 0 00-.072.222l.79 4.607a.25.25 0 01-.363.264l-4.137-2.176a.25.25 0 00-.233 0l-4.138 2.175a.25.25 0 01-.362-.263l.79-4.607a.25.25 0 00-.072-.222L4.753 9.882a.25.25 0 01.14-.427l4.625-.672zM12 14.533c.28 0 .559.067.814.2l1.895.997-.362-2.11a1.75 1.75 0 01.504-1.55l1.533-1.495-2.12-.308a1.75 1.75 0 01-1.317-.957L12 7.39v7.143z"
  1242. }));
  1243. /* harmony default export */ var star_half = (starHalf);
  1244. ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/star-empty.js
  1245. /**
  1246. * WordPress dependencies
  1247. */
  1248. const starEmpty = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
  1249. xmlns: "http://www.w3.org/2000/svg",
  1250. viewBox: "0 0 24 24"
  1251. }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
  1252. fillRule: "evenodd",
  1253. d: "M9.706 8.646a.25.25 0 01-.188.137l-4.626.672a.25.25 0 00-.139.427l3.348 3.262a.25.25 0 01.072.222l-.79 4.607a.25.25 0 00.362.264l4.138-2.176a.25.25 0 01.233 0l4.137 2.175a.25.25 0 00.363-.263l-.79-4.607a.25.25 0 01.072-.222l3.347-3.262a.25.25 0 00-.139-.427l-4.626-.672a.25.25 0 01-.188-.137l-2.069-4.192a.25.25 0 00-.448 0L9.706 8.646zM12 7.39l-.948 1.921a1.75 1.75 0 01-1.317.957l-2.12.308 1.534 1.495c.412.402.6.982.503 1.55l-.362 2.11 1.896-.997a1.75 1.75 0 011.629 0l1.895.997-.362-2.11a1.75 1.75 0 01.504-1.55l1.533-1.495-2.12-.308a1.75 1.75 0 01-1.317-.957L12 7.39z",
  1254. clipRule: "evenodd"
  1255. }));
  1256. /* harmony default export */ var star_empty = (starEmpty);
  1257. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-directory/build-module/components/block-ratings/stars.js
  1258. /**
  1259. * WordPress dependencies
  1260. */
  1261. function Stars({
  1262. rating
  1263. }) {
  1264. const stars = Math.round(rating / 0.5) * 0.5;
  1265. const fullStarCount = Math.floor(rating);
  1266. const halfStarCount = Math.ceil(rating - fullStarCount);
  1267. const emptyStarCount = 5 - (fullStarCount + halfStarCount);
  1268. return (0,external_wp_element_namespaceObject.createElement)("span", {
  1269. "aria-label": (0,external_wp_i18n_namespaceObject.sprintf)( /* translators: %s: number of stars. */
  1270. (0,external_wp_i18n_namespaceObject.__)('%s out of 5 stars'), stars)
  1271. }, Array.from({
  1272. length: fullStarCount
  1273. }).map((_, i) => (0,external_wp_element_namespaceObject.createElement)(icon, {
  1274. key: `full_stars_${i}`,
  1275. className: "block-directory-block-ratings__star-full",
  1276. icon: star_filled,
  1277. size: 16
  1278. })), Array.from({
  1279. length: halfStarCount
  1280. }).map((_, i) => (0,external_wp_element_namespaceObject.createElement)(icon, {
  1281. key: `half_stars_${i}`,
  1282. className: "block-directory-block-ratings__star-half-full",
  1283. icon: star_half,
  1284. size: 16
  1285. })), Array.from({
  1286. length: emptyStarCount
  1287. }).map((_, i) => (0,external_wp_element_namespaceObject.createElement)(icon, {
  1288. key: `empty_stars_${i}`,
  1289. className: "block-directory-block-ratings__star-empty",
  1290. icon: star_empty,
  1291. size: 16
  1292. })));
  1293. }
  1294. /* harmony default export */ var stars = (Stars);
  1295. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-directory/build-module/components/block-ratings/index.js
  1296. /**
  1297. * Internal dependencies
  1298. */
  1299. const BlockRatings = ({
  1300. rating
  1301. }) => (0,external_wp_element_namespaceObject.createElement)("span", {
  1302. className: "block-directory-block-ratings"
  1303. }, (0,external_wp_element_namespaceObject.createElement)(stars, {
  1304. rating: rating
  1305. }));
  1306. /* harmony default export */ var block_ratings = (BlockRatings);
  1307. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-directory/build-module/components/downloadable-block-icon/index.js
  1308. /**
  1309. * WordPress dependencies
  1310. */
  1311. function DownloadableBlockIcon({
  1312. icon
  1313. }) {
  1314. const className = 'block-directory-downloadable-block-icon';
  1315. return icon.match(/\.(jpeg|jpg|gif|png|svg)(?:\?.*)?$/) !== null ? (0,external_wp_element_namespaceObject.createElement)("img", {
  1316. className: className,
  1317. src: icon,
  1318. alt: ""
  1319. }) : (0,external_wp_element_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.BlockIcon, {
  1320. className: className,
  1321. icon: icon,
  1322. showColors: true
  1323. });
  1324. }
  1325. /* harmony default export */ var downloadable_block_icon = (DownloadableBlockIcon);
  1326. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-directory/build-module/components/downloadable-block-notice/index.js
  1327. /**
  1328. * WordPress dependencies
  1329. */
  1330. /**
  1331. * Internal dependencies
  1332. */
  1333. const DownloadableBlockNotice = ({
  1334. block
  1335. }) => {
  1336. const errorNotice = (0,external_wp_data_namespaceObject.useSelect)(select => select(store).getErrorNoticeForBlock(block.id), [block]);
  1337. if (!errorNotice) {
  1338. return null;
  1339. }
  1340. return (0,external_wp_element_namespaceObject.createElement)("div", {
  1341. className: "block-directory-downloadable-block-notice"
  1342. }, (0,external_wp_element_namespaceObject.createElement)("div", {
  1343. className: "block-directory-downloadable-block-notice__content"
  1344. }, errorNotice.message, errorNotice.isFatal ? ' ' + (0,external_wp_i18n_namespaceObject.__)('Try reloading the page.') : null));
  1345. };
  1346. /* harmony default export */ var downloadable_block_notice = (DownloadableBlockNotice);
  1347. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-directory/build-module/components/downloadable-block-list-item/index.js
  1348. /**
  1349. * WordPress dependencies
  1350. */
  1351. /**
  1352. * Internal dependencies
  1353. */
  1354. // Return the appropriate block item label, given the block data and status.
  1355. function getDownloadableBlockLabel({
  1356. title,
  1357. rating,
  1358. ratingCount
  1359. }, {
  1360. hasNotice,
  1361. isInstalled,
  1362. isInstalling
  1363. }) {
  1364. const stars = Math.round(rating / 0.5) * 0.5;
  1365. if (!isInstalled && hasNotice) {
  1366. /* translators: %1$s: block title */
  1367. return (0,external_wp_i18n_namespaceObject.sprintf)('Retry installing %s.', (0,external_wp_htmlEntities_namespaceObject.decodeEntities)(title));
  1368. }
  1369. if (isInstalled) {
  1370. /* translators: %1$s: block title */
  1371. return (0,external_wp_i18n_namespaceObject.sprintf)('Add %s.', (0,external_wp_htmlEntities_namespaceObject.decodeEntities)(title));
  1372. }
  1373. if (isInstalling) {
  1374. /* translators: %1$s: block title */
  1375. return (0,external_wp_i18n_namespaceObject.sprintf)('Installing %s.', (0,external_wp_htmlEntities_namespaceObject.decodeEntities)(title));
  1376. }
  1377. // No ratings yet, just use the title.
  1378. if (ratingCount < 1) {
  1379. /* translators: %1$s: block title */
  1380. return (0,external_wp_i18n_namespaceObject.sprintf)('Install %s.', (0,external_wp_htmlEntities_namespaceObject.decodeEntities)(title));
  1381. }
  1382. return (0,external_wp_i18n_namespaceObject.sprintf)( /* translators: %1$s: block title, %2$s: average rating, %3$s: total ratings count. */
  1383. (0,external_wp_i18n_namespaceObject._n)('Install %1$s. %2$s stars with %3$s review.', 'Install %1$s. %2$s stars with %3$s reviews.', ratingCount), (0,external_wp_htmlEntities_namespaceObject.decodeEntities)(title), stars, ratingCount);
  1384. }
  1385. function DownloadableBlockListItem({
  1386. composite,
  1387. item,
  1388. onClick
  1389. }) {
  1390. const {
  1391. author,
  1392. description,
  1393. icon,
  1394. rating,
  1395. title
  1396. } = item;
  1397. // getBlockType returns a block object if this block exists, or null if not.
  1398. const isInstalled = !!(0,external_wp_blocks_namespaceObject.getBlockType)(item.name);
  1399. const {
  1400. hasNotice,
  1401. isInstalling,
  1402. isInstallable
  1403. } = (0,external_wp_data_namespaceObject.useSelect)(select => {
  1404. const {
  1405. getErrorNoticeForBlock,
  1406. isInstalling: isBlockInstalling
  1407. } = select(store);
  1408. const notice = getErrorNoticeForBlock(item.id);
  1409. const hasFatal = notice && notice.isFatal;
  1410. return {
  1411. hasNotice: !!notice,
  1412. isInstalling: isBlockInstalling(item.id),
  1413. isInstallable: !hasFatal
  1414. };
  1415. }, [item]);
  1416. let statusText = '';
  1417. if (isInstalled) {
  1418. statusText = (0,external_wp_i18n_namespaceObject.__)('Installed!');
  1419. } else if (isInstalling) {
  1420. statusText = (0,external_wp_i18n_namespaceObject.__)('Installing…');
  1421. }
  1422. return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__unstableCompositeItem, {
  1423. __experimentalIsFocusable: true,
  1424. role: "option",
  1425. as: external_wp_components_namespaceObject.Button,
  1426. ...composite,
  1427. className: "block-directory-downloadable-block-list-item",
  1428. onClick: event => {
  1429. event.preventDefault();
  1430. onClick();
  1431. },
  1432. isBusy: isInstalling,
  1433. disabled: isInstalling || !isInstallable,
  1434. label: getDownloadableBlockLabel(item, {
  1435. hasNotice,
  1436. isInstalled,
  1437. isInstalling
  1438. }),
  1439. showTooltip: true,
  1440. tooltipPosition: "top center"
  1441. }, (0,external_wp_element_namespaceObject.createElement)("div", {
  1442. className: "block-directory-downloadable-block-list-item__icon"
  1443. }, (0,external_wp_element_namespaceObject.createElement)(downloadable_block_icon, {
  1444. icon: icon,
  1445. title: title
  1446. }), isInstalling ? (0,external_wp_element_namespaceObject.createElement)("span", {
  1447. className: "block-directory-downloadable-block-list-item__spinner"
  1448. }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Spinner, null)) : (0,external_wp_element_namespaceObject.createElement)(block_ratings, {
  1449. rating: rating
  1450. })), (0,external_wp_element_namespaceObject.createElement)("span", {
  1451. className: "block-directory-downloadable-block-list-item__details"
  1452. }, (0,external_wp_element_namespaceObject.createElement)("span", {
  1453. className: "block-directory-downloadable-block-list-item__title"
  1454. }, (0,external_wp_element_namespaceObject.createInterpolateElement)((0,external_wp_i18n_namespaceObject.sprintf)( /* translators: %1$s: block title, %2$s: author name. */
  1455. (0,external_wp_i18n_namespaceObject.__)('%1$s <span>by %2$s</span>'), (0,external_wp_htmlEntities_namespaceObject.decodeEntities)(title), author), {
  1456. span: (0,external_wp_element_namespaceObject.createElement)("span", {
  1457. className: "block-directory-downloadable-block-list-item__author"
  1458. })
  1459. })), hasNotice ? (0,external_wp_element_namespaceObject.createElement)(downloadable_block_notice, {
  1460. block: item
  1461. }) : (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)("span", {
  1462. className: "block-directory-downloadable-block-list-item__desc"
  1463. }, !!statusText ? statusText : (0,external_wp_htmlEntities_namespaceObject.decodeEntities)(description)), isInstallable && !(isInstalled || isInstalling) && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.VisuallyHidden, null, (0,external_wp_i18n_namespaceObject.__)('Install block')))));
  1464. }
  1465. /* harmony default export */ var downloadable_block_list_item = (DownloadableBlockListItem);
  1466. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-directory/build-module/components/downloadable-blocks-list/index.js
  1467. /**
  1468. * WordPress dependencies
  1469. */
  1470. /**
  1471. * Internal dependencies
  1472. */
  1473. const noop = () => {};
  1474. function DownloadableBlocksList({
  1475. items,
  1476. onHover = noop,
  1477. onSelect
  1478. }) {
  1479. const composite = (0,external_wp_components_namespaceObject.__unstableUseCompositeState)();
  1480. const {
  1481. installBlockType
  1482. } = (0,external_wp_data_namespaceObject.useDispatch)(store);
  1483. if (!items.length) {
  1484. return null;
  1485. }
  1486. return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__unstableComposite, {
  1487. ...composite,
  1488. role: "listbox",
  1489. className: "block-directory-downloadable-blocks-list",
  1490. "aria-label": (0,external_wp_i18n_namespaceObject.__)('Blocks available for install')
  1491. }, items.map(item => {
  1492. return (0,external_wp_element_namespaceObject.createElement)(downloadable_block_list_item, {
  1493. key: item.id,
  1494. composite: composite,
  1495. onClick: () => {
  1496. // Check if the block is registered (`getBlockType`
  1497. // will return an object). If so, insert the block.
  1498. // This prevents installing existing plugins.
  1499. if ((0,external_wp_blocks_namespaceObject.getBlockType)(item.name)) {
  1500. onSelect(item);
  1501. } else {
  1502. installBlockType(item).then(success => {
  1503. if (success) {
  1504. onSelect(item);
  1505. }
  1506. });
  1507. }
  1508. onHover(null);
  1509. },
  1510. onHover: onHover,
  1511. item: item
  1512. });
  1513. }));
  1514. }
  1515. /* harmony default export */ var downloadable_blocks_list = (DownloadableBlocksList);
  1516. ;// CONCATENATED MODULE: external ["wp","a11y"]
  1517. var external_wp_a11y_namespaceObject = window["wp"]["a11y"];
  1518. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-directory/build-module/components/downloadable-blocks-panel/inserter-panel.js
  1519. /**
  1520. * WordPress dependencies
  1521. */
  1522. function DownloadableBlocksInserterPanel({
  1523. children,
  1524. downloadableItems,
  1525. hasLocalBlocks
  1526. }) {
  1527. const count = downloadableItems.length;
  1528. (0,external_wp_element_namespaceObject.useEffect)(() => {
  1529. (0,external_wp_a11y_namespaceObject.speak)((0,external_wp_i18n_namespaceObject.sprintf)( /* translators: %d: number of available blocks. */
  1530. (0,external_wp_i18n_namespaceObject._n)('%d additional block is available to install.', '%d additional blocks are available to install.', count), count));
  1531. }, [count]);
  1532. return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, !hasLocalBlocks && (0,external_wp_element_namespaceObject.createElement)("p", {
  1533. className: "block-directory-downloadable-blocks-panel__no-local"
  1534. }, (0,external_wp_i18n_namespaceObject.__)('No results available from your installed blocks.')), (0,external_wp_element_namespaceObject.createElement)("div", {
  1535. className: "block-editor-inserter__quick-inserter-separator"
  1536. }), (0,external_wp_element_namespaceObject.createElement)("div", {
  1537. className: "block-directory-downloadable-blocks-panel"
  1538. }, (0,external_wp_element_namespaceObject.createElement)("div", {
  1539. className: "block-directory-downloadable-blocks-panel__header"
  1540. }, (0,external_wp_element_namespaceObject.createElement)("h2", {
  1541. className: "block-directory-downloadable-blocks-panel__title"
  1542. }, (0,external_wp_i18n_namespaceObject.__)('Available to install')), (0,external_wp_element_namespaceObject.createElement)("p", {
  1543. className: "block-directory-downloadable-blocks-panel__description"
  1544. }, (0,external_wp_i18n_namespaceObject.__)('Select a block to install and add it to your post.'))), children));
  1545. }
  1546. /* harmony default export */ var inserter_panel = (DownloadableBlocksInserterPanel);
  1547. ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/block-default.js
  1548. /**
  1549. * WordPress dependencies
  1550. */
  1551. const blockDefault = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
  1552. xmlns: "http://www.w3.org/2000/svg",
  1553. viewBox: "0 0 24 24"
  1554. }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
  1555. d: "M19 8h-1V6h-5v2h-2V6H6v2H5c-1.1 0-2 .9-2 2v8c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2v-8c0-1.1-.9-2-2-2zm.5 10c0 .3-.2.5-.5.5H5c-.3 0-.5-.2-.5-.5v-8c0-.3.2-.5.5-.5h14c.3 0 .5.2.5.5v8z"
  1556. }));
  1557. /* harmony default export */ var block_default = (blockDefault);
  1558. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-directory/build-module/components/downloadable-blocks-panel/no-results.js
  1559. /**
  1560. * WordPress dependencies
  1561. */
  1562. function DownloadableBlocksNoResults() {
  1563. return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)("div", {
  1564. className: "block-editor-inserter__no-results"
  1565. }, (0,external_wp_element_namespaceObject.createElement)(icon, {
  1566. className: "block-editor-inserter__no-results-icon",
  1567. icon: block_default
  1568. }), (0,external_wp_element_namespaceObject.createElement)("p", null, (0,external_wp_i18n_namespaceObject.__)('No results found.'))), (0,external_wp_element_namespaceObject.createElement)("div", {
  1569. className: "block-editor-inserter__tips"
  1570. }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Tip, null, (0,external_wp_i18n_namespaceObject.__)('Interested in creating your own block?'), (0,external_wp_element_namespaceObject.createElement)("br", null), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.ExternalLink, {
  1571. href: "https://developer.wordpress.org/block-editor/"
  1572. }, (0,external_wp_i18n_namespaceObject.__)('Get started here'), "."))));
  1573. }
  1574. /* harmony default export */ var no_results = (DownloadableBlocksNoResults);
  1575. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-directory/build-module/components/downloadable-blocks-panel/index.js
  1576. /**
  1577. * WordPress dependencies
  1578. */
  1579. /**
  1580. * Internal dependencies
  1581. */
  1582. const EMPTY_ARRAY = [];
  1583. function DownloadableBlocksPanel({
  1584. downloadableItems,
  1585. onSelect,
  1586. onHover,
  1587. hasLocalBlocks,
  1588. hasPermission,
  1589. isLoading,
  1590. isTyping
  1591. }) {
  1592. if (typeof hasPermission === 'undefined' || isLoading || isTyping) {
  1593. return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, hasPermission && !hasLocalBlocks && (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)("p", {
  1594. className: "block-directory-downloadable-blocks-panel__no-local"
  1595. }, (0,external_wp_i18n_namespaceObject.__)('No results available from your installed blocks.')), (0,external_wp_element_namespaceObject.createElement)("div", {
  1596. className: "block-editor-inserter__quick-inserter-separator"
  1597. })), (0,external_wp_element_namespaceObject.createElement)("div", {
  1598. className: "block-directory-downloadable-blocks-panel has-blocks-loading"
  1599. }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Spinner, null)));
  1600. }
  1601. if (false === hasPermission) {
  1602. if (!hasLocalBlocks) {
  1603. return (0,external_wp_element_namespaceObject.createElement)(no_results, null);
  1604. }
  1605. return null;
  1606. }
  1607. return !!downloadableItems.length ? (0,external_wp_element_namespaceObject.createElement)(inserter_panel, {
  1608. downloadableItems: downloadableItems,
  1609. hasLocalBlocks: hasLocalBlocks
  1610. }, (0,external_wp_element_namespaceObject.createElement)(downloadable_blocks_list, {
  1611. items: downloadableItems,
  1612. onSelect: onSelect,
  1613. onHover: onHover
  1614. })) : !hasLocalBlocks && (0,external_wp_element_namespaceObject.createElement)(no_results, null);
  1615. }
  1616. /* harmony default export */ var downloadable_blocks_panel = ((0,external_wp_compose_namespaceObject.compose)([(0,external_wp_data_namespaceObject.withSelect)((select, {
  1617. filterValue,
  1618. rootClientId = null
  1619. }) => {
  1620. const {
  1621. getDownloadableBlocks,
  1622. isRequestingDownloadableBlocks
  1623. } = select(store);
  1624. const {
  1625. canInsertBlockType
  1626. } = select(external_wp_blockEditor_namespaceObject.store);
  1627. const hasPermission = select(external_wp_coreData_namespaceObject.store).canUser('read', 'block-directory/search');
  1628. function getInstallableBlocks(term) {
  1629. const downloadableBlocks = getDownloadableBlocks(term);
  1630. const installableBlocks = downloadableBlocks.filter(block => canInsertBlockType(block, rootClientId, true));
  1631. if (downloadableBlocks.length === installableBlocks.length) {
  1632. return downloadableBlocks;
  1633. }
  1634. return installableBlocks;
  1635. }
  1636. let downloadableItems = hasPermission ? getInstallableBlocks(filterValue) : [];
  1637. if (downloadableItems.length === 0) {
  1638. downloadableItems = EMPTY_ARRAY;
  1639. }
  1640. const isLoading = isRequestingDownloadableBlocks(filterValue);
  1641. return {
  1642. downloadableItems,
  1643. hasPermission,
  1644. isLoading
  1645. };
  1646. })])(DownloadableBlocksPanel));
  1647. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-directory/build-module/plugins/inserter-menu-downloadable-blocks-panel/index.js
  1648. /**
  1649. * WordPress dependencies
  1650. */
  1651. /**
  1652. * Internal dependencies
  1653. */
  1654. function InserterMenuDownloadableBlocksPanel() {
  1655. const [debouncedFilterValue, setFilterValue] = (0,external_wp_element_namespaceObject.useState)('');
  1656. const debouncedSetFilterValue = (0,external_wp_compose_namespaceObject.debounce)(setFilterValue, 400);
  1657. return (0,external_wp_element_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.__unstableInserterMenuExtension, null, ({
  1658. onSelect,
  1659. onHover,
  1660. filterValue,
  1661. hasItems,
  1662. rootClientId
  1663. }) => {
  1664. if (debouncedFilterValue !== filterValue) {
  1665. debouncedSetFilterValue(filterValue);
  1666. }
  1667. if (!debouncedFilterValue) {
  1668. return null;
  1669. }
  1670. return (0,external_wp_element_namespaceObject.createElement)(downloadable_blocks_panel, {
  1671. onSelect: onSelect,
  1672. onHover: onHover,
  1673. rootClientId: rootClientId,
  1674. filterValue: debouncedFilterValue,
  1675. hasLocalBlocks: hasItems,
  1676. isTyping: filterValue !== debouncedFilterValue
  1677. });
  1678. });
  1679. }
  1680. /* harmony default export */ var inserter_menu_downloadable_blocks_panel = (InserterMenuDownloadableBlocksPanel);
  1681. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-directory/build-module/components/compact-list/index.js
  1682. /**
  1683. * WordPress dependencies
  1684. */
  1685. /**
  1686. * Internal dependencies
  1687. */
  1688. function CompactList({
  1689. items
  1690. }) {
  1691. if (!items.length) {
  1692. return null;
  1693. }
  1694. return (0,external_wp_element_namespaceObject.createElement)("ul", {
  1695. className: "block-directory-compact-list"
  1696. }, items.map(({
  1697. icon,
  1698. id,
  1699. title,
  1700. author
  1701. }) => (0,external_wp_element_namespaceObject.createElement)("li", {
  1702. key: id,
  1703. className: "block-directory-compact-list__item"
  1704. }, (0,external_wp_element_namespaceObject.createElement)(downloadable_block_icon, {
  1705. icon: icon,
  1706. title: title
  1707. }), (0,external_wp_element_namespaceObject.createElement)("div", {
  1708. className: "block-directory-compact-list__item-details"
  1709. }, (0,external_wp_element_namespaceObject.createElement)("div", {
  1710. className: "block-directory-compact-list__item-title"
  1711. }, title), (0,external_wp_element_namespaceObject.createElement)("div", {
  1712. className: "block-directory-compact-list__item-author"
  1713. }, (0,external_wp_i18n_namespaceObject.sprintf)( /* translators: %s: Name of the block author. */
  1714. (0,external_wp_i18n_namespaceObject.__)('By %s'), author))))));
  1715. }
  1716. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-directory/build-module/plugins/installed-blocks-pre-publish-panel/index.js
  1717. var _window$wp$editPost;
  1718. /**
  1719. * WordPress dependencies
  1720. */
  1721. /**
  1722. * Internal dependencies
  1723. */
  1724. // We shouldn't import the edit-post package directly
  1725. // because it would include the wp-edit-post in all pages loading the block-directory script.
  1726. const {
  1727. PluginPrePublishPanel
  1728. } = (_window$wp$editPost = window?.wp?.editPost) !== null && _window$wp$editPost !== void 0 ? _window$wp$editPost : {};
  1729. function InstalledBlocksPrePublishPanel() {
  1730. const newBlockTypes = (0,external_wp_data_namespaceObject.useSelect)(select => select(store).getNewBlockTypes(), []);
  1731. if (!newBlockTypes.length) {
  1732. return null;
  1733. }
  1734. return (0,external_wp_element_namespaceObject.createElement)(PluginPrePublishPanel, {
  1735. icon: block_default,
  1736. title: (0,external_wp_i18n_namespaceObject.sprintf)(
  1737. // translators: %d: number of blocks (number).
  1738. (0,external_wp_i18n_namespaceObject._n)('Added: %d block', 'Added: %d blocks', newBlockTypes.length), newBlockTypes.length),
  1739. initialOpen: true
  1740. }, (0,external_wp_element_namespaceObject.createElement)("p", {
  1741. className: "installed-blocks-pre-publish-panel__copy"
  1742. }, (0,external_wp_i18n_namespaceObject._n)('The following block has been added to your site.', 'The following blocks have been added to your site.', newBlockTypes.length)), (0,external_wp_element_namespaceObject.createElement)(CompactList, {
  1743. items: newBlockTypes
  1744. }));
  1745. }
  1746. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-directory/build-module/plugins/get-install-missing/install-button.js
  1747. /**
  1748. * WordPress dependencies
  1749. */
  1750. /**
  1751. * Internal dependencies
  1752. */
  1753. function InstallButton({
  1754. attributes,
  1755. block,
  1756. clientId
  1757. }) {
  1758. const isInstallingBlock = (0,external_wp_data_namespaceObject.useSelect)(select => select(store).isInstalling(block.id), [block.id]);
  1759. const {
  1760. installBlockType
  1761. } = (0,external_wp_data_namespaceObject.useDispatch)(store);
  1762. const {
  1763. replaceBlock
  1764. } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_blockEditor_namespaceObject.store);
  1765. return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, {
  1766. onClick: () => installBlockType(block).then(success => {
  1767. if (success) {
  1768. const blockType = (0,external_wp_blocks_namespaceObject.getBlockType)(block.name);
  1769. const [originalBlock] = (0,external_wp_blocks_namespaceObject.parse)(attributes.originalContent);
  1770. if (originalBlock && blockType) {
  1771. replaceBlock(clientId, (0,external_wp_blocks_namespaceObject.createBlock)(blockType.name, originalBlock.attributes, originalBlock.innerBlocks));
  1772. }
  1773. }
  1774. }),
  1775. disabled: isInstallingBlock,
  1776. isBusy: isInstallingBlock,
  1777. variant: "primary"
  1778. }, (0,external_wp_i18n_namespaceObject.sprintf)( /* translators: %s: block name */
  1779. (0,external_wp_i18n_namespaceObject.__)('Install %s'), block.title));
  1780. }
  1781. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-directory/build-module/plugins/get-install-missing/index.js
  1782. /**
  1783. * WordPress dependencies
  1784. */
  1785. /**
  1786. * Internal dependencies
  1787. */
  1788. const getInstallMissing = OriginalComponent => props => {
  1789. const {
  1790. originalName
  1791. } = props.attributes;
  1792. // Disable reason: This is a valid component, but it's mistaken for a callback.
  1793. // eslint-disable-next-line react-hooks/rules-of-hooks
  1794. const {
  1795. block,
  1796. hasPermission
  1797. } = (0,external_wp_data_namespaceObject.useSelect)(select => {
  1798. const {
  1799. getDownloadableBlocks
  1800. } = select(store);
  1801. const blocks = getDownloadableBlocks('block:' + originalName).filter(({
  1802. name
  1803. }) => originalName === name);
  1804. return {
  1805. hasPermission: select(external_wp_coreData_namespaceObject.store).canUser('read', 'block-directory/search'),
  1806. block: blocks.length && blocks[0]
  1807. };
  1808. }, [originalName]);
  1809. // The user can't install blocks, or the block isn't available for download.
  1810. if (!hasPermission || !block) {
  1811. return (0,external_wp_element_namespaceObject.createElement)(OriginalComponent, {
  1812. ...props
  1813. });
  1814. }
  1815. return (0,external_wp_element_namespaceObject.createElement)(ModifiedWarning, {
  1816. ...props,
  1817. originalBlock: block
  1818. });
  1819. };
  1820. const ModifiedWarning = ({
  1821. originalBlock,
  1822. ...props
  1823. }) => {
  1824. const {
  1825. originalName,
  1826. originalUndelimitedContent,
  1827. clientId
  1828. } = props.attributes;
  1829. const {
  1830. replaceBlock
  1831. } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_blockEditor_namespaceObject.store);
  1832. const convertToHTML = () => {
  1833. replaceBlock(props.clientId, (0,external_wp_blocks_namespaceObject.createBlock)('core/html', {
  1834. content: originalUndelimitedContent
  1835. }));
  1836. };
  1837. const hasContent = !!originalUndelimitedContent;
  1838. const hasHTMLBlock = (0,external_wp_data_namespaceObject.useSelect)(select => {
  1839. const {
  1840. canInsertBlockType,
  1841. getBlockRootClientId
  1842. } = select(external_wp_blockEditor_namespaceObject.store);
  1843. return canInsertBlockType('core/html', getBlockRootClientId(clientId));
  1844. }, [clientId]);
  1845. let messageHTML = (0,external_wp_i18n_namespaceObject.sprintf)( /* translators: %s: block name */
  1846. (0,external_wp_i18n_namespaceObject.__)('Your site doesn’t include support for the %s block. You can try installing the block or remove it entirely.'), originalBlock.title || originalName);
  1847. const actions = [(0,external_wp_element_namespaceObject.createElement)(InstallButton, {
  1848. key: "install",
  1849. block: originalBlock,
  1850. attributes: props.attributes,
  1851. clientId: props.clientId
  1852. })];
  1853. if (hasContent && hasHTMLBlock) {
  1854. messageHTML = (0,external_wp_i18n_namespaceObject.sprintf)( /* translators: %s: block name */
  1855. (0,external_wp_i18n_namespaceObject.__)('Your site doesn’t include support for the %s block. You can try installing the block, convert it to a Custom HTML block, or remove it entirely.'), originalBlock.title || originalName);
  1856. actions.push((0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, {
  1857. key: "convert",
  1858. onClick: convertToHTML,
  1859. variant: "tertiary"
  1860. }, (0,external_wp_i18n_namespaceObject.__)('Keep as HTML')));
  1861. }
  1862. return (0,external_wp_element_namespaceObject.createElement)("div", {
  1863. ...(0,external_wp_blockEditor_namespaceObject.useBlockProps)()
  1864. }, (0,external_wp_element_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.Warning, {
  1865. actions: actions
  1866. }, messageHTML), (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.RawHTML, null, originalUndelimitedContent));
  1867. };
  1868. /* harmony default export */ var get_install_missing = (getInstallMissing);
  1869. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-directory/build-module/plugins/index.js
  1870. /**
  1871. * WordPress dependencies
  1872. */
  1873. /**
  1874. * Internal dependencies
  1875. */
  1876. (0,external_wp_plugins_namespaceObject.registerPlugin)('block-directory', {
  1877. render() {
  1878. return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)(AutoBlockUninstaller, null), (0,external_wp_element_namespaceObject.createElement)(inserter_menu_downloadable_blocks_panel, null), (0,external_wp_element_namespaceObject.createElement)(InstalledBlocksPrePublishPanel, null));
  1879. }
  1880. });
  1881. (0,external_wp_hooks_namespaceObject.addFilter)('blocks.registerBlockType', 'block-directory/fallback', (settings, name) => {
  1882. if (name !== 'core/missing') {
  1883. return settings;
  1884. }
  1885. settings.edit = get_install_missing(settings.edit);
  1886. return settings;
  1887. });
  1888. ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-directory/build-module/index.js
  1889. /**
  1890. * Internal dependencies
  1891. */
  1892. (window.wp = window.wp || {}).blockDirectory = __webpack_exports__;
  1893. /******/ })()
  1894. ;