@wordpress/block-directory 6.0.0 → 6.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (106) hide show
  1. package/build/components/auto-block-uninstaller/index.cjs +26 -47
  2. package/build/components/auto-block-uninstaller/index.cjs.map +1 -7
  3. package/build/components/block-ratings/index.cjs +28 -34
  4. package/build/components/block-ratings/index.cjs.map +1 -7
  5. package/build/components/block-ratings/stars.cjs +35 -71
  6. package/build/components/block-ratings/stars.cjs.map +1 -7
  7. package/build/components/compact-list/index.cjs +45 -43
  8. package/build/components/compact-list/index.cjs.map +1 -7
  9. package/build/components/downloadable-block-icon/index.cjs +20 -29
  10. package/build/components/downloadable-block-icon/index.cjs.map +1 -7
  11. package/build/components/downloadable-block-list-item/index.cjs +95 -161
  12. package/build/components/downloadable-block-list-item/index.cjs.map +1 -7
  13. package/build/components/downloadable-block-notice/index.cjs +22 -46
  14. package/build/components/downloadable-block-notice/index.cjs.map +1 -7
  15. package/build/components/downloadable-blocks-list/index.cjs +50 -70
  16. package/build/components/downloadable-blocks-list/index.cjs.map +1 -7
  17. package/build/components/downloadable-blocks-panel/index.cjs +79 -119
  18. package/build/components/downloadable-blocks-panel/index.cjs.map +1 -7
  19. package/build/components/downloadable-blocks-panel/inserter-panel.cjs +37 -61
  20. package/build/components/downloadable-blocks-panel/inserter-panel.cjs.map +1 -7
  21. package/build/components/downloadable-blocks-panel/no-results.cjs +27 -46
  22. package/build/components/downloadable-blocks-panel/no-results.cjs.map +1 -7
  23. package/build/index.cjs +11 -29
  24. package/build/plugins/get-install-missing/index.cjs +80 -122
  25. package/build/plugins/get-install-missing/index.cjs.map +1 -7
  26. package/build/plugins/get-install-missing/install-button.cjs +33 -70
  27. package/build/plugins/get-install-missing/install-button.cjs.map +1 -7
  28. package/build/plugins/index.cjs +45 -45
  29. package/build/plugins/index.cjs.map +1 -7
  30. package/build/plugins/inserter-menu-downloadable-blocks-panel/index.cjs +40 -52
  31. package/build/plugins/inserter-menu-downloadable-blocks-panel/index.cjs.map +1 -7
  32. package/build/plugins/installed-blocks-pre-publish-panel/index.cjs +38 -62
  33. package/build/plugins/installed-blocks-pre-publish-panel/index.cjs.map +1 -7
  34. package/build/store/actions.cjs +233 -205
  35. package/build/store/actions.cjs.map +1 -7
  36. package/build/store/index.cjs +56 -45
  37. package/build/store/index.cjs.map +1 -7
  38. package/build/store/load-assets.cjs +62 -63
  39. package/build/store/load-assets.cjs.map +1 -7
  40. package/build/store/reducer.cjs +90 -101
  41. package/build/store/reducer.cjs.map +1 -7
  42. package/build/store/resolvers.cjs +34 -54
  43. package/build/store/resolvers.cjs.map +1 -7
  44. package/build/store/selectors.cjs +111 -107
  45. package/build/store/selectors.cjs.map +1 -7
  46. package/build/store/utils/get-plugin-url.cjs +19 -32
  47. package/build/store/utils/get-plugin-url.cjs.map +1 -7
  48. package/build-module/components/auto-block-uninstaller/index.mjs +19 -25
  49. package/build-module/components/auto-block-uninstaller/index.mjs.map +1 -7
  50. package/build-module/components/block-ratings/index.mjs +8 -8
  51. package/build-module/components/block-ratings/index.mjs.map +1 -7
  52. package/build-module/components/block-ratings/stars.mjs +28 -49
  53. package/build-module/components/block-ratings/stars.mjs.map +1 -7
  54. package/build-module/components/compact-list/index.mjs +24 -19
  55. package/build-module/components/compact-list/index.mjs.map +1 -7
  56. package/build-module/components/downloadable-block-icon/index.mjs +14 -8
  57. package/build-module/components/downloadable-block-icon/index.mjs.map +1 -7
  58. package/build-module/components/downloadable-block-list-item/index.mjs +64 -130
  59. package/build-module/components/downloadable-block-list-item/index.mjs.map +1 -7
  60. package/build-module/components/downloadable-block-notice/index.mjs +16 -22
  61. package/build-module/components/downloadable-block-notice/index.mjs.map +1 -7
  62. package/build-module/components/downloadable-blocks-list/index.mjs +26 -43
  63. package/build-module/components/downloadable-blocks-list/index.mjs.map +1 -7
  64. package/build-module/components/downloadable-blocks-panel/index.mjs +52 -91
  65. package/build-module/components/downloadable-blocks-panel/index.mjs.map +1 -7
  66. package/build-module/components/downloadable-blocks-panel/inserter-panel.mjs +29 -38
  67. package/build-module/components/downloadable-blocks-panel/inserter-panel.mjs.map +1 -7
  68. package/build-module/components/downloadable-blocks-panel/no-results.mjs +19 -23
  69. package/build-module/components/downloadable-blocks-panel/no-results.mjs.map +1 -7
  70. package/build-module/index.mjs +1 -6
  71. package/build-module/plugins/get-install-missing/index.mjs +55 -98
  72. package/build-module/plugins/get-install-missing/index.mjs.map +1 -7
  73. package/build-module/plugins/get-install-missing/install-button.mjs +25 -47
  74. package/build-module/plugins/get-install-missing/install-button.mjs.map +1 -7
  75. package/build-module/plugins/index.mjs +16 -23
  76. package/build-module/plugins/index.mjs.map +1 -7
  77. package/build-module/plugins/inserter-menu-downloadable-blocks-panel/index.mjs +17 -26
  78. package/build-module/plugins/inserter-menu-downloadable-blocks-panel/index.mjs.map +1 -7
  79. package/build-module/plugins/installed-blocks-pre-publish-panel/index.mjs +15 -36
  80. package/build-module/plugins/installed-blocks-pre-publish-panel/index.mjs.map +1 -7
  81. package/build-module/store/actions.mjs +201 -170
  82. package/build-module/store/actions.mjs.map +1 -7
  83. package/build-module/store/index.mjs +28 -13
  84. package/build-module/store/index.mjs.map +1 -7
  85. package/build-module/store/load-assets.mjs +42 -36
  86. package/build-module/store/load-assets.mjs.map +1 -7
  87. package/build-module/store/reducer.mjs +81 -74
  88. package/build-module/store/reducer.mjs.map +1 -7
  89. package/build-module/store/resolvers.mjs +13 -26
  90. package/build-module/store/resolvers.mjs.map +1 -7
  91. package/build-module/store/selectors.mjs +99 -76
  92. package/build-module/store/selectors.mjs.map +1 -7
  93. package/build-module/store/utils/get-plugin-url.mjs +14 -12
  94. package/build-module/store/utils/get-plugin-url.mjs.map +1 -7
  95. package/build-style/style-rtl.css +6 -12
  96. package/build-style/style.css +6 -12
  97. package/package.json +22 -23
  98. package/src/components/downloadable-block-list-item/style.scss +6 -6
  99. package/src/components/downloadable-block-notice/index.jsx +0 -4
  100. package/build/index.cjs.map +0 -7
  101. package/build/lock-unlock.cjs +0 -36
  102. package/build/lock-unlock.cjs.map +0 -7
  103. package/build-module/index.mjs.map +0 -7
  104. package/build-module/lock-unlock.mjs +0 -11
  105. package/build-module/lock-unlock.mjs.map +0 -7
  106. package/src/lock-unlock.js +0 -7
@@ -1,7 +1 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../src/store/actions.js"],
4
- "sourcesContent": ["import {\n\tstore as blocksStore,\n\tunstable__bootstrapServerSideBlockDefinitions, // eslint-disable-line camelcase\n} from '@wordpress/blocks';\nimport { __, sprintf } from '@wordpress/i18n';\nimport apiFetch from '@wordpress/api-fetch';\nimport { store as noticesStore } from '@wordpress/notices';\nimport { addQueryArgs } from '@wordpress/url';\nimport { loadAssets } from './load-assets';\nimport getPluginUrl from './utils/get-plugin-url';\n\n/**\n * Returns an action object used in signalling that the downloadable blocks\n * have been requested and are loading.\n *\n * @param {string} filterValue Search string.\n *\n * @return {Object} Action object.\n */\nexport function fetchDownloadableBlocks( filterValue ) {\n\treturn { type: 'FETCH_DOWNLOADABLE_BLOCKS', filterValue };\n}\n\n/**\n * Returns an action object used in signalling that the downloadable blocks\n * have been updated.\n *\n * @param {Array} downloadableBlocks Downloadable blocks.\n * @param {string} filterValue Search string.\n *\n * @return {Object} Action object.\n */\nexport function receiveDownloadableBlocks( downloadableBlocks, filterValue ) {\n\treturn {\n\t\ttype: 'RECEIVE_DOWNLOADABLE_BLOCKS',\n\t\tdownloadableBlocks,\n\t\tfilterValue,\n\t};\n}\n\n/**\n * Action triggered to install a block plugin.\n *\n * @param {Object} block The block item returned by search.\n *\n * @return {boolean} Whether the block was successfully installed & loaded.\n */\nexport const installBlockType =\n\t( block ) =>\n\tasync ( { registry, dispatch } ) => {\n\t\tconst { id, name } = block;\n\t\tlet success = false;\n\t\tdispatch.clearErrorNotice( id );\n\t\ttry {\n\t\t\tdispatch.setIsInstalling( id, true );\n\n\t\t\t// If we have a wp:plugin link, the plugin is installed but inactive.\n\t\t\tconst url = getPluginUrl( block );\n\t\t\tlet links = {};\n\t\t\tif ( url ) {\n\t\t\t\tawait apiFetch( {\n\t\t\t\t\tmethod: 'PUT',\n\t\t\t\t\turl,\n\t\t\t\t\tdata: { status: 'active' },\n\t\t\t\t} );\n\t\t\t} else {\n\t\t\t\tconst response = await apiFetch( {\n\t\t\t\t\tmethod: 'POST',\n\t\t\t\t\tpath: 'wp/v2/plugins',\n\t\t\t\t\tdata: { slug: id, status: 'active' },\n\t\t\t\t} );\n\t\t\t\t// Add the `self` link for newly-installed blocks.\n\t\t\t\tlinks = response._links;\n\t\t\t}\n\n\t\t\tdispatch.addInstalledBlockType( {\n\t\t\t\t...block,\n\t\t\t\tlinks: { ...block.links, ...links },\n\t\t\t} );\n\n\t\t\t// Ensures that the block metadata is propagated to the editor when registered on the server.\n\t\t\tconst metadataFields = [\n\t\t\t\t'api_version',\n\t\t\t\t'title',\n\t\t\t\t'category',\n\t\t\t\t'parent',\n\t\t\t\t'ancestor',\n\t\t\t\t'icon',\n\t\t\t\t'description',\n\t\t\t\t'keywords',\n\t\t\t\t'attributes',\n\t\t\t\t'provides_context',\n\t\t\t\t'uses_context',\n\t\t\t\t'selectors',\n\t\t\t\t'supports',\n\t\t\t\t'styles',\n\t\t\t\t'example',\n\t\t\t\t'variations',\n\t\t\t\t'allowed_blocks',\n\t\t\t\t'block_hooks',\n\t\t\t];\n\t\t\tawait apiFetch( {\n\t\t\t\tpath: addQueryArgs( `/wp/v2/block-types/${ name }`, {\n\t\t\t\t\t_fields: metadataFields,\n\t\t\t\t} ),\n\t\t\t} )\n\t\t\t\t// Ignore when the block is not registered on the server.\n\t\t\t\t.catch( () => {} )\n\t\t\t\t.then( ( response ) => {\n\t\t\t\t\tif ( ! response ) {\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t\tunstable__bootstrapServerSideBlockDefinitions( {\n\t\t\t\t\t\t[ name ]: Object.fromEntries(\n\t\t\t\t\t\t\tObject.entries( response ).filter( ( [ key ] ) =>\n\t\t\t\t\t\t\t\tmetadataFields.includes( key )\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t),\n\t\t\t\t\t} );\n\t\t\t\t} );\n\n\t\t\tawait loadAssets();\n\t\t\tconst registeredBlocks = registry\n\t\t\t\t.select( blocksStore )\n\t\t\t\t.getBlockTypes();\n\t\t\tif ( ! registeredBlocks.some( ( i ) => i.name === name ) ) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t__( 'Error registering block. Try reloading the page.' )\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tregistry.dispatch( noticesStore ).createInfoNotice(\n\t\t\t\tsprintf(\n\t\t\t\t\t// translators: %s is the block title.\n\t\t\t\t\t__( 'Block %s installed and added.' ),\n\t\t\t\t\tblock.title\n\t\t\t\t),\n\t\t\t\t{\n\t\t\t\t\tspeak: true,\n\t\t\t\t\ttype: 'snackbar',\n\t\t\t\t}\n\t\t\t);\n\t\t\tsuccess = true;\n\t\t} catch ( error ) {\n\t\t\tlet message = error.message || __( 'An error occurred.' );\n\n\t\t\t// Errors we throw are fatal.\n\t\t\tlet isFatal = error instanceof Error;\n\n\t\t\t// Specific API errors that are fatal.\n\t\t\tconst fatalAPIErrors = {\n\t\t\t\tfolder_exists: __(\n\t\t\t\t\t'This block is already installed. Try reloading the page.'\n\t\t\t\t),\n\t\t\t\tunable_to_connect_to_filesystem: __(\n\t\t\t\t\t'Error installing block. You can reload the page and try again.'\n\t\t\t\t),\n\t\t\t};\n\n\t\t\tif ( fatalAPIErrors[ error.code ] ) {\n\t\t\t\tisFatal = true;\n\t\t\t\tmessage = fatalAPIErrors[ error.code ];\n\t\t\t}\n\n\t\t\tdispatch.setErrorNotice( id, message, isFatal );\n\t\t\tregistry.dispatch( noticesStore ).createErrorNotice( message, {\n\t\t\t\tspeak: true,\n\t\t\t\tisDismissible: true,\n\t\t\t} );\n\t\t}\n\t\tdispatch.setIsInstalling( id, false );\n\t\treturn success;\n\t};\n\n/**\n * Action triggered to uninstall a block plugin.\n *\n * @param {Object} block The blockType object.\n */\nexport const uninstallBlockType =\n\t( block ) =>\n\tasync ( { registry, dispatch } ) => {\n\t\ttry {\n\t\t\tconst url = getPluginUrl( block );\n\t\t\tawait apiFetch( {\n\t\t\t\tmethod: 'PUT',\n\t\t\t\turl,\n\t\t\t\tdata: { status: 'inactive' },\n\t\t\t} );\n\t\t\tawait apiFetch( {\n\t\t\t\tmethod: 'DELETE',\n\t\t\t\turl,\n\t\t\t} );\n\t\t\tdispatch.removeInstalledBlockType( block );\n\t\t} catch ( error ) {\n\t\t\tregistry\n\t\t\t\t.dispatch( noticesStore )\n\t\t\t\t.createErrorNotice(\n\t\t\t\t\terror.message || __( 'An error occurred.' )\n\t\t\t\t);\n\t\t}\n\t};\n\n/**\n * Returns an action object used to add a block type to the \"newly installed\"\n * tracking list.\n *\n * @param {Object} item The block item with the block id and name.\n *\n * @return {Object} Action object.\n */\nexport function addInstalledBlockType( item ) {\n\treturn {\n\t\ttype: 'ADD_INSTALLED_BLOCK_TYPE',\n\t\titem,\n\t};\n}\n\n/**\n * Returns an action object used to remove a block type from the \"newly installed\"\n * tracking list.\n *\n * @param {string} item The block item with the block id and name.\n *\n * @return {Object} Action object.\n */\nexport function removeInstalledBlockType( item ) {\n\treturn {\n\t\ttype: 'REMOVE_INSTALLED_BLOCK_TYPE',\n\t\titem,\n\t};\n}\n\n/**\n * Returns an action object used to indicate install in progress.\n *\n * @param {string} blockId\n * @param {boolean} isInstalling\n *\n * @return {Object} Action object.\n */\nexport function setIsInstalling( blockId, isInstalling ) {\n\treturn {\n\t\ttype: 'SET_INSTALLING_BLOCK',\n\t\tblockId,\n\t\tisInstalling,\n\t};\n}\n\n/**\n * Sets an error notice to be displayed to the user for a given block.\n *\n * @param {string} blockId The ID of the block plugin. eg: my-block\n * @param {string} message The message shown in the notice.\n * @param {boolean} isFatal Whether the user can recover from the error.\n *\n * @return {Object} Action object.\n */\nexport function setErrorNotice( blockId, message, isFatal = false ) {\n\treturn {\n\t\ttype: 'SET_ERROR_NOTICE',\n\t\tblockId,\n\t\tmessage,\n\t\tisFatal,\n\t};\n}\n\n/**\n * Sets the error notice to empty for specific block.\n *\n * @param {string} blockId The ID of the block plugin. eg: my-block\n *\n * @return {Object} Action object.\n */\nexport function clearErrorNotice( blockId ) {\n\treturn {\n\t\ttype: 'CLEAR_ERROR_NOTICE',\n\t\tblockId,\n\t};\n}\n"],
5
- "mappings": "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",
6
- "names": ["getPluginUrl", "apiFetch", "blocksStore", "noticesStore"]
7
- }
1
+ {"version":3,"file":"actions.cjs","names":["getPluginUrl","apiFetch","addQueryArgs","loadAssets","blocksStore","__","noticesStore","sprintf"],"sources":["../../src/store/actions.js"],"sourcesContent":["import {\n\tstore as blocksStore,\n\tunstable__bootstrapServerSideBlockDefinitions, // eslint-disable-line camelcase\n} from '@wordpress/blocks';\nimport { __, sprintf } from '@wordpress/i18n';\nimport apiFetch from '@wordpress/api-fetch';\nimport { store as noticesStore } from '@wordpress/notices';\nimport { addQueryArgs } from '@wordpress/url';\nimport { loadAssets } from './load-assets';\nimport getPluginUrl from './utils/get-plugin-url';\n\n/**\n * Returns an action object used in signalling that the downloadable blocks\n * have been requested and are loading.\n *\n * @param {string} filterValue Search string.\n *\n * @return {Object} Action object.\n */\nexport function fetchDownloadableBlocks( filterValue ) {\n\treturn { type: 'FETCH_DOWNLOADABLE_BLOCKS', filterValue };\n}\n\n/**\n * Returns an action object used in signalling that the downloadable blocks\n * have been updated.\n *\n * @param {Array} downloadableBlocks Downloadable blocks.\n * @param {string} filterValue Search string.\n *\n * @return {Object} Action object.\n */\nexport function receiveDownloadableBlocks( downloadableBlocks, filterValue ) {\n\treturn {\n\t\ttype: 'RECEIVE_DOWNLOADABLE_BLOCKS',\n\t\tdownloadableBlocks,\n\t\tfilterValue,\n\t};\n}\n\n/**\n * Action triggered to install a block plugin.\n *\n * @param {Object} block The block item returned by search.\n *\n * @return {boolean} Whether the block was successfully installed & loaded.\n */\nexport const installBlockType =\n\t( block ) =>\n\tasync ( { registry, dispatch } ) => {\n\t\tconst { id, name } = block;\n\t\tlet success = false;\n\t\tdispatch.clearErrorNotice( id );\n\t\ttry {\n\t\t\tdispatch.setIsInstalling( id, true );\n\n\t\t\t// If we have a wp:plugin link, the plugin is installed but inactive.\n\t\t\tconst url = getPluginUrl( block );\n\t\t\tlet links = {};\n\t\t\tif ( url ) {\n\t\t\t\tawait apiFetch( {\n\t\t\t\t\tmethod: 'PUT',\n\t\t\t\t\turl,\n\t\t\t\t\tdata: { status: 'active' },\n\t\t\t\t} );\n\t\t\t} else {\n\t\t\t\tconst response = await apiFetch( {\n\t\t\t\t\tmethod: 'POST',\n\t\t\t\t\tpath: 'wp/v2/plugins',\n\t\t\t\t\tdata: { slug: id, status: 'active' },\n\t\t\t\t} );\n\t\t\t\t// Add the `self` link for newly-installed blocks.\n\t\t\t\tlinks = response._links;\n\t\t\t}\n\n\t\t\tdispatch.addInstalledBlockType( {\n\t\t\t\t...block,\n\t\t\t\tlinks: { ...block.links, ...links },\n\t\t\t} );\n\n\t\t\t// Ensures that the block metadata is propagated to the editor when registered on the server.\n\t\t\tconst metadataFields = [\n\t\t\t\t'api_version',\n\t\t\t\t'title',\n\t\t\t\t'category',\n\t\t\t\t'parent',\n\t\t\t\t'ancestor',\n\t\t\t\t'icon',\n\t\t\t\t'description',\n\t\t\t\t'keywords',\n\t\t\t\t'attributes',\n\t\t\t\t'provides_context',\n\t\t\t\t'uses_context',\n\t\t\t\t'selectors',\n\t\t\t\t'supports',\n\t\t\t\t'styles',\n\t\t\t\t'example',\n\t\t\t\t'variations',\n\t\t\t\t'allowed_blocks',\n\t\t\t\t'block_hooks',\n\t\t\t];\n\t\t\tawait apiFetch( {\n\t\t\t\tpath: addQueryArgs( `/wp/v2/block-types/${ name }`, {\n\t\t\t\t\t_fields: metadataFields,\n\t\t\t\t} ),\n\t\t\t} )\n\t\t\t\t// Ignore when the block is not registered on the server.\n\t\t\t\t.catch( () => {} )\n\t\t\t\t.then( ( response ) => {\n\t\t\t\t\tif ( ! response ) {\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t\tunstable__bootstrapServerSideBlockDefinitions( {\n\t\t\t\t\t\t[ name ]: Object.fromEntries(\n\t\t\t\t\t\t\tObject.entries( response ).filter( ( [ key ] ) =>\n\t\t\t\t\t\t\t\tmetadataFields.includes( key )\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t),\n\t\t\t\t\t} );\n\t\t\t\t} );\n\n\t\t\tawait loadAssets();\n\t\t\tconst registeredBlocks = registry\n\t\t\t\t.select( blocksStore )\n\t\t\t\t.getBlockTypes();\n\t\t\tif ( ! registeredBlocks.some( ( i ) => i.name === name ) ) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t__( 'Error registering block. Try reloading the page.' )\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tregistry.dispatch( noticesStore ).createInfoNotice(\n\t\t\t\tsprintf(\n\t\t\t\t\t// translators: %s is the block title.\n\t\t\t\t\t__( 'Block %s installed and added.' ),\n\t\t\t\t\tblock.title\n\t\t\t\t),\n\t\t\t\t{\n\t\t\t\t\tspeak: true,\n\t\t\t\t\ttype: 'snackbar',\n\t\t\t\t}\n\t\t\t);\n\t\t\tsuccess = true;\n\t\t} catch ( error ) {\n\t\t\tlet message = error.message || __( 'An error occurred.' );\n\n\t\t\t// Errors we throw are fatal.\n\t\t\tlet isFatal = error instanceof Error;\n\n\t\t\t// Specific API errors that are fatal.\n\t\t\tconst fatalAPIErrors = {\n\t\t\t\tfolder_exists: __(\n\t\t\t\t\t'This block is already installed. Try reloading the page.'\n\t\t\t\t),\n\t\t\t\tunable_to_connect_to_filesystem: __(\n\t\t\t\t\t'Error installing block. You can reload the page and try again.'\n\t\t\t\t),\n\t\t\t};\n\n\t\t\tif ( fatalAPIErrors[ error.code ] ) {\n\t\t\t\tisFatal = true;\n\t\t\t\tmessage = fatalAPIErrors[ error.code ];\n\t\t\t}\n\n\t\t\tdispatch.setErrorNotice( id, message, isFatal );\n\t\t\tregistry.dispatch( noticesStore ).createErrorNotice( message, {\n\t\t\t\tspeak: true,\n\t\t\t\tisDismissible: true,\n\t\t\t} );\n\t\t}\n\t\tdispatch.setIsInstalling( id, false );\n\t\treturn success;\n\t};\n\n/**\n * Action triggered to uninstall a block plugin.\n *\n * @param {Object} block The blockType object.\n */\nexport const uninstallBlockType =\n\t( block ) =>\n\tasync ( { registry, dispatch } ) => {\n\t\ttry {\n\t\t\tconst url = getPluginUrl( block );\n\t\t\tawait apiFetch( {\n\t\t\t\tmethod: 'PUT',\n\t\t\t\turl,\n\t\t\t\tdata: { status: 'inactive' },\n\t\t\t} );\n\t\t\tawait apiFetch( {\n\t\t\t\tmethod: 'DELETE',\n\t\t\t\turl,\n\t\t\t} );\n\t\t\tdispatch.removeInstalledBlockType( block );\n\t\t} catch ( error ) {\n\t\t\tregistry\n\t\t\t\t.dispatch( noticesStore )\n\t\t\t\t.createErrorNotice(\n\t\t\t\t\terror.message || __( 'An error occurred.' )\n\t\t\t\t);\n\t\t}\n\t};\n\n/**\n * Returns an action object used to add a block type to the \"newly installed\"\n * tracking list.\n *\n * @param {Object} item The block item with the block id and name.\n *\n * @return {Object} Action object.\n */\nexport function addInstalledBlockType( item ) {\n\treturn {\n\t\ttype: 'ADD_INSTALLED_BLOCK_TYPE',\n\t\titem,\n\t};\n}\n\n/**\n * Returns an action object used to remove a block type from the \"newly installed\"\n * tracking list.\n *\n * @param {string} item The block item with the block id and name.\n *\n * @return {Object} Action object.\n */\nexport function removeInstalledBlockType( item ) {\n\treturn {\n\t\ttype: 'REMOVE_INSTALLED_BLOCK_TYPE',\n\t\titem,\n\t};\n}\n\n/**\n * Returns an action object used to indicate install in progress.\n *\n * @param {string} blockId\n * @param {boolean} isInstalling\n *\n * @return {Object} Action object.\n */\nexport function setIsInstalling( blockId, isInstalling ) {\n\treturn {\n\t\ttype: 'SET_INSTALLING_BLOCK',\n\t\tblockId,\n\t\tisInstalling,\n\t};\n}\n\n/**\n * Sets an error notice to be displayed to the user for a given block.\n *\n * @param {string} blockId The ID of the block plugin. eg: my-block\n * @param {string} message The message shown in the notice.\n * @param {boolean} isFatal Whether the user can recover from the error.\n *\n * @return {Object} Action object.\n */\nexport function setErrorNotice( blockId, message, isFatal = false ) {\n\treturn {\n\t\ttype: 'SET_ERROR_NOTICE',\n\t\tblockId,\n\t\tmessage,\n\t\tisFatal,\n\t};\n}\n\n/**\n * Sets the error notice to empty for specific block.\n *\n * @param {string} blockId The ID of the block plugin. eg: my-block\n *\n * @return {Object} Action object.\n */\nexport function clearErrorNotice( blockId ) {\n\treturn {\n\t\ttype: 'CLEAR_ERROR_NOTICE',\n\t\tblockId,\n\t};\n}\n"],"mappings":"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"}
@@ -1,55 +1,66 @@
1
+ "use strict";
2
+ Object.defineProperties(exports, {
3
+ __esModule: { value: true },
4
+ [Symbol.toStringTag]: { value: "Module" }
5
+ });
6
+ // \0rolldown/runtime.js
1
7
  var __create = Object.create;
2
8
  var __defProp = Object.defineProperty;
3
9
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
10
  var __getOwnPropNames = Object.getOwnPropertyNames;
5
11
  var __getProtoOf = Object.getPrototypeOf;
6
12
  var __hasOwnProp = Object.prototype.hasOwnProperty;
7
- var __export = (target, all) => {
8
- for (var name in all)
9
- __defProp(target, name, { get: all[name], enumerable: true });
10
- };
11
13
  var __copyProps = (to, from, except, desc) => {
12
- if (from && typeof from === "object" || typeof from === "function") {
13
- for (let key of __getOwnPropNames(from))
14
- if (!__hasOwnProp.call(to, key) && key !== except)
15
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
- }
17
- return to;
14
+ if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
15
+ key = keys[i];
16
+ if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
17
+ get: ((k) => from[k]).bind(null, key),
18
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
19
+ });
20
+ }
21
+ return to;
18
22
  };
19
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
20
- // If the importer is in node compatibility mode or this is not an ESM
21
- // file that has been converted to a CommonJS file using a Babel-
22
- // compatible transform (i.e. "__esModule" has not been set), then set
23
- // "default" to the CommonJS "module.exports" for node compatibility.
24
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
25
- mod
26
- ));
27
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
28
-
23
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
24
+ value: mod,
25
+ enumerable: true
26
+ }) : target, mod));
27
+ let _wordpress_data = require("@wordpress/data");
28
+ let __reducer_js = require("./reducer.cjs");
29
+ __reducer_js = __toESM(__reducer_js);
30
+ let __selectors_js = require("./selectors.cjs");
31
+ __selectors_js = __toESM(__selectors_js);
32
+ let __actions_js = require("./actions.cjs");
33
+ __actions_js = __toESM(__actions_js);
34
+ let __resolvers_js = require("./resolvers.cjs");
35
+ __resolvers_js = __toESM(__resolvers_js);
29
36
  // packages/block-directory/src/store/index.js
30
- var store_exports = {};
31
- __export(store_exports, {
32
- store: () => store,
33
- storeConfig: () => storeConfig
34
- });
35
- module.exports = __toCommonJS(store_exports);
36
- var import_data = require("@wordpress/data");
37
- var import_reducer = __toESM(require("./reducer.cjs"));
38
- var selectors = __toESM(require("./selectors.cjs"));
39
- var actions = __toESM(require("./actions.cjs"));
40
- var resolvers = __toESM(require("./resolvers.cjs"));
41
- var STORE_NAME = "core/block-directory";
42
- var storeConfig = {
43
- reducer: import_reducer.default,
44
- selectors,
45
- actions,
46
- resolvers
37
+ /**
38
+ * Module Constants
39
+ */
40
+ const STORE_NAME = "core/block-directory";
41
+ /**
42
+ * Block editor data store configuration.
43
+ *
44
+ * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/data/README.md#registerStore
45
+ *
46
+ * @type {Object}
47
+ */
48
+ const storeConfig = {
49
+ reducer: __reducer_js.default,
50
+ selectors: __selectors_js,
51
+ actions: __actions_js,
52
+ resolvers: __resolvers_js
47
53
  };
48
- var store = (0, import_data.createReduxStore)(STORE_NAME, storeConfig);
49
- (0, import_data.register)(store);
50
- // Annotate the CommonJS export names for ESM import in node:
51
- 0 && (module.exports = {
52
- store,
53
- storeConfig
54
- });
55
- //# sourceMappingURL=index.cjs.map
54
+ /**
55
+ * Store definition for the block directory namespace.
56
+ *
57
+ * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/data/README.md#createReduxStore
58
+ *
59
+ * @type {Object}
60
+ */
61
+ const store = (0, _wordpress_data.createReduxStore)(STORE_NAME, storeConfig);
62
+ (0, _wordpress_data.register)(store);
63
+ exports.store = store;
64
+ exports.storeConfig = storeConfig;
65
+
66
+ //# sourceMappingURL=index.cjs.map
@@ -1,7 +1 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../src/store/index.js"],
4
- "sourcesContent": ["import { createReduxStore, register } from '@wordpress/data';\nimport reducer from './reducer';\nimport * as selectors from './selectors';\nimport * as actions from './actions';\nimport * as resolvers from './resolvers';\n\n/**\n * Module Constants\n */\nconst STORE_NAME = 'core/block-directory';\n\n/**\n * Block editor data store configuration.\n *\n * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/data/README.md#registerStore\n *\n * @type {Object}\n */\nexport const storeConfig = {\n\treducer,\n\tselectors,\n\tactions,\n\tresolvers,\n};\n\n/**\n * Store definition for the block directory namespace.\n *\n * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/data/README.md#createReduxStore\n *\n * @type {Object}\n */\nexport const store = createReduxStore( STORE_NAME, storeConfig );\n\nregister( store );\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAA2C;AAC3C,qBAAoB;AACpB,gBAA2B;AAC3B,cAAyB;AACzB,gBAA2B;AAK3B,IAAM,aAAa;AASZ,IAAM,cAAc;AAAA,EAC1B,wBAAAA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACD;AASO,IAAM,YAAQ,8BAAkB,YAAY,WAAY;AAAA,IAE/D,sBAAU,KAAM;",
6
- "names": ["reducer"]
7
- }
1
+ {"version":3,"file":"index.cjs","names":["createReduxStore","register"],"sources":["../../src/store/index.js"],"sourcesContent":["import { createReduxStore, register } from '@wordpress/data';\nimport reducer from './reducer';\nimport * as selectors from './selectors';\nimport * as actions from './actions';\nimport * as resolvers from './resolvers';\n\n/**\n * Module Constants\n */\nconst STORE_NAME = 'core/block-directory';\n\n/**\n * Block editor data store configuration.\n *\n * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/data/README.md#registerStore\n *\n * @type {Object}\n */\nexport const storeConfig = {\n\treducer,\n\tselectors,\n\tactions,\n\tresolvers,\n};\n\n/**\n * Store definition for the block directory namespace.\n *\n * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/data/README.md#createReduxStore\n *\n * @type {Object}\n */\nexport const store = createReduxStore( STORE_NAME, storeConfig );\n\nregister( store );\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AASA,MAAM,aAAa;;;;;;;;AASnB,MAAa,cAAc;CAC1B,SAAA,aAAA;CACA,WAAA;CACA,SAAA;CACA,WAAA;AACD;;;;;;;;AASA,MAAa,SAAA,GAAQA,gBAAAA,iBAAAA,CAAkB,YAAY,WAAY;CAE/DC,GAAAA,gBAAAA,SAAAA,CAAU,KAAM"}
@@ -1,75 +1,74 @@
1
+ "use strict";
2
+ Object.defineProperties(exports, {
3
+ __esModule: { value: true },
4
+ [Symbol.toStringTag]: { value: "Module" }
5
+ });
6
+ // \0rolldown/runtime.js
1
7
  var __create = Object.create;
2
8
  var __defProp = Object.defineProperty;
3
9
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
10
  var __getOwnPropNames = Object.getOwnPropertyNames;
5
11
  var __getProtoOf = Object.getPrototypeOf;
6
12
  var __hasOwnProp = Object.prototype.hasOwnProperty;
7
- var __export = (target, all) => {
8
- for (var name in all)
9
- __defProp(target, name, { get: all[name], enumerable: true });
10
- };
11
13
  var __copyProps = (to, from, except, desc) => {
12
- if (from && typeof from === "object" || typeof from === "function") {
13
- for (let key of __getOwnPropNames(from))
14
- if (!__hasOwnProp.call(to, key) && key !== except)
15
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
- }
17
- return to;
14
+ if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
15
+ key = keys[i];
16
+ if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
17
+ get: ((k) => from[k]).bind(null, key),
18
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
19
+ });
20
+ }
21
+ return to;
18
22
  };
19
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
20
- // If the importer is in node compatibility mode or this is not an ESM
21
- // file that has been converted to a CommonJS file using a Babel-
22
- // compatible transform (i.e. "__esModule" has not been set), then set
23
- // "default" to the CommonJS "module.exports" for node compatibility.
24
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
25
- mod
26
- ));
27
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
28
-
23
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
24
+ value: mod,
25
+ enumerable: true
26
+ }) : target, mod));
27
+ let _wordpress_api_fetch = require("@wordpress/api-fetch");
28
+ _wordpress_api_fetch = __toESM(_wordpress_api_fetch);
29
29
  // packages/block-directory/src/store/load-assets.js
30
- var load_assets_exports = {};
31
- __export(load_assets_exports, {
32
- loadAsset: () => loadAsset,
33
- loadAssets: () => loadAssets
34
- });
35
- module.exports = __toCommonJS(load_assets_exports);
36
- var import_api_fetch = __toESM(require("@wordpress/api-fetch"));
37
- var loadAsset = (el) => {
38
- return new Promise((resolve, reject) => {
39
- const newNode = document.createElement(el.nodeName);
40
- ["id", "rel", "src", "href", "type"].forEach((attr) => {
41
- if (el[attr]) {
42
- newNode[attr] = el[attr];
43
- }
44
- });
45
- if (el.innerHTML) {
46
- newNode.appendChild(document.createTextNode(el.innerHTML));
47
- }
48
- newNode.onload = () => resolve(true);
49
- newNode.onerror = () => reject(new Error("Error loading asset."));
50
- document.body.appendChild(newNode);
51
- if ("link" === newNode.nodeName.toLowerCase() || "script" === newNode.nodeName.toLowerCase() && !newNode.src) {
52
- resolve();
53
- }
54
- });
30
+ /**
31
+ * Load an asset for a block.
32
+ *
33
+ * This function returns a Promise that will resolve once the asset is loaded,
34
+ * or in the case of Stylesheets and Inline JavaScript, will resolve immediately.
35
+ *
36
+ * @param {HTMLElement} el A HTML Element asset to inject.
37
+ *
38
+ * @return {Promise} Promise which will resolve when the asset is loaded.
39
+ */
40
+ const loadAsset = (el) => {
41
+ return new Promise((resolve, reject) => {
42
+ const newNode = document.createElement(el.nodeName);
43
+ [
44
+ "id",
45
+ "rel",
46
+ "src",
47
+ "href",
48
+ "type"
49
+ ].forEach((attr) => {
50
+ if (el[attr]) newNode[attr] = el[attr];
51
+ });
52
+ if (el.innerHTML) newNode.appendChild(document.createTextNode(el.innerHTML));
53
+ newNode.onload = () => resolve(true);
54
+ newNode.onerror = () => reject(/* @__PURE__ */ new Error("Error loading asset."));
55
+ document.body.appendChild(newNode);
56
+ if ("link" === newNode.nodeName.toLowerCase() || "script" === newNode.nodeName.toLowerCase() && !newNode.src) resolve();
57
+ });
55
58
  };
59
+ /**
60
+ * Load the asset files for a block
61
+ */
56
62
  async function loadAssets() {
57
- const response = await (0, import_api_fetch.default)({
58
- url: document.location.href,
59
- parse: false
60
- });
61
- const data = await response.text();
62
- const doc = new window.DOMParser().parseFromString(data, "text/html");
63
- const newAssets = Array.from(
64
- doc.querySelectorAll('link[rel="stylesheet"],script')
65
- ).filter((asset) => asset.id && !document.getElementById(asset.id));
66
- for (const newAsset of newAssets) {
67
- await loadAsset(newAsset);
68
- }
63
+ const data = await (await (0, _wordpress_api_fetch.default)({
64
+ url: document.location.href,
65
+ parse: false
66
+ })).text();
67
+ const doc = new window.DOMParser().parseFromString(data, "text/html");
68
+ const newAssets = Array.from(doc.querySelectorAll("link[rel=\"stylesheet\"],script")).filter((asset) => asset.id && !document.getElementById(asset.id));
69
+ for (const newAsset of newAssets) await loadAsset(newAsset);
69
70
  }
70
- // Annotate the CommonJS export names for ESM import in node:
71
- 0 && (module.exports = {
72
- loadAsset,
73
- loadAssets
74
- });
75
- //# sourceMappingURL=load-assets.cjs.map
71
+ exports.loadAsset = loadAsset;
72
+ exports.loadAssets = loadAssets;
73
+
74
+ //# sourceMappingURL=load-assets.cjs.map
@@ -1,7 +1 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../src/store/load-assets.js"],
4
- "sourcesContent": ["import apiFetch from '@wordpress/api-fetch';\n\n/**\n * Load an asset for a block.\n *\n * This function returns a Promise that will resolve once the asset is loaded,\n * or in the case of Stylesheets and Inline JavaScript, will resolve immediately.\n *\n * @param {HTMLElement} el A HTML Element asset to inject.\n *\n * @return {Promise} Promise which will resolve when the asset is loaded.\n */\nexport const loadAsset = ( el ) => {\n\treturn new Promise( ( resolve, reject ) => {\n\t\t/*\n\t\t * Reconstruct the passed element, this is required as inserting the Node directly\n\t\t * won't always fire the required onload events, even if the asset wasn't already loaded.\n\t\t */\n\t\tconst newNode = document.createElement( el.nodeName );\n\n\t\t[ 'id', 'rel', 'src', 'href', 'type' ].forEach( ( attr ) => {\n\t\t\tif ( el[ attr ] ) {\n\t\t\t\tnewNode[ attr ] = el[ attr ];\n\t\t\t}\n\t\t} );\n\n\t\t// Append inline <script> contents.\n\t\tif ( el.innerHTML ) {\n\t\t\tnewNode.appendChild( document.createTextNode( el.innerHTML ) );\n\t\t}\n\n\t\tnewNode.onload = () => resolve( true );\n\t\tnewNode.onerror = () => reject( new Error( 'Error loading asset.' ) );\n\n\t\tdocument.body.appendChild( newNode );\n\n\t\t// Resolve Stylesheets and Inline JavaScript immediately.\n\t\tif (\n\t\t\t'link' === newNode.nodeName.toLowerCase() ||\n\t\t\t( 'script' === newNode.nodeName.toLowerCase() && ! newNode.src )\n\t\t) {\n\t\t\tresolve();\n\t\t}\n\t} );\n};\n\n/**\n * Load the asset files for a block\n */\nexport async function loadAssets() {\n\t/*\n\t * Fetch the current URL (post-new.php, or post.php?post=1&action=edit) and compare the\n\t * JavaScript and CSS assets loaded between the pages. This imports the required assets\n\t * for the block into the current page while not requiring that we know them up-front.\n\t * In the future this can be improved by reliance upon block.json and/or a script-loader\n\t * dependency API.\n\t */\n\tconst response = await apiFetch( {\n\t\turl: document.location.href,\n\t\tparse: false,\n\t} );\n\n\tconst data = await response.text();\n\n\tconst doc = new window.DOMParser().parseFromString( data, 'text/html' );\n\n\tconst newAssets = Array.from(\n\t\tdoc.querySelectorAll( 'link[rel=\"stylesheet\"],script' )\n\t).filter( ( asset ) => asset.id && ! document.getElementById( asset.id ) );\n\n\t/*\n\t * Load each asset in order, as they may depend upon an earlier loaded script.\n\t * Stylesheets and Inline Scripts will resolve immediately upon insertion.\n\t */\n\tfor ( const newAsset of newAssets ) {\n\t\tawait loadAsset( newAsset );\n\t}\n}\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,uBAAqB;AAYd,IAAM,YAAY,CAAE,OAAQ;AAClC,SAAO,IAAI,QAAS,CAAE,SAAS,WAAY;AAK1C,UAAM,UAAU,SAAS,cAAe,GAAG,QAAS;AAEpD,KAAE,MAAM,OAAO,OAAO,QAAQ,MAAO,EAAE,QAAS,CAAE,SAAU;AAC3D,UAAK,GAAI,IAAK,GAAI;AACjB,gBAAS,IAAK,IAAI,GAAI,IAAK;AAAA,MAC5B;AAAA,IACD,CAAE;AAGF,QAAK,GAAG,WAAY;AACnB,cAAQ,YAAa,SAAS,eAAgB,GAAG,SAAU,CAAE;AAAA,IAC9D;AAEA,YAAQ,SAAS,MAAM,QAAS,IAAK;AACrC,YAAQ,UAAU,MAAM,OAAQ,IAAI,MAAO,sBAAuB,CAAE;AAEpE,aAAS,KAAK,YAAa,OAAQ;AAGnC,QACC,WAAW,QAAQ,SAAS,YAAY,KACtC,aAAa,QAAQ,SAAS,YAAY,KAAK,CAAE,QAAQ,KAC1D;AACD,cAAQ;AAAA,IACT;AAAA,EACD,CAAE;AACH;AAKA,eAAsB,aAAa;AAQlC,QAAM,WAAW,UAAM,iBAAAA,SAAU;AAAA,IAChC,KAAK,SAAS,SAAS;AAAA,IACvB,OAAO;AAAA,EACR,CAAE;AAEF,QAAM,OAAO,MAAM,SAAS,KAAK;AAEjC,QAAM,MAAM,IAAI,OAAO,UAAU,EAAE,gBAAiB,MAAM,WAAY;AAEtE,QAAM,YAAY,MAAM;AAAA,IACvB,IAAI,iBAAkB,+BAAgC;AAAA,EACvD,EAAE,OAAQ,CAAE,UAAW,MAAM,MAAM,CAAE,SAAS,eAAgB,MAAM,EAAG,CAAE;AAMzE,aAAY,YAAY,WAAY;AACnC,UAAM,UAAW,QAAS;AAAA,EAC3B;AACD;",
6
- "names": ["apiFetch"]
7
- }
1
+ {"version":3,"file":"load-assets.cjs","names":["apiFetch"],"sources":["../../src/store/load-assets.js"],"sourcesContent":["import apiFetch from '@wordpress/api-fetch';\n\n/**\n * Load an asset for a block.\n *\n * This function returns a Promise that will resolve once the asset is loaded,\n * or in the case of Stylesheets and Inline JavaScript, will resolve immediately.\n *\n * @param {HTMLElement} el A HTML Element asset to inject.\n *\n * @return {Promise} Promise which will resolve when the asset is loaded.\n */\nexport const loadAsset = ( el ) => {\n\treturn new Promise( ( resolve, reject ) => {\n\t\t/*\n\t\t * Reconstruct the passed element, this is required as inserting the Node directly\n\t\t * won't always fire the required onload events, even if the asset wasn't already loaded.\n\t\t */\n\t\tconst newNode = document.createElement( el.nodeName );\n\n\t\t[ 'id', 'rel', 'src', 'href', 'type' ].forEach( ( attr ) => {\n\t\t\tif ( el[ attr ] ) {\n\t\t\t\tnewNode[ attr ] = el[ attr ];\n\t\t\t}\n\t\t} );\n\n\t\t// Append inline <script> contents.\n\t\tif ( el.innerHTML ) {\n\t\t\tnewNode.appendChild( document.createTextNode( el.innerHTML ) );\n\t\t}\n\n\t\tnewNode.onload = () => resolve( true );\n\t\tnewNode.onerror = () => reject( new Error( 'Error loading asset.' ) );\n\n\t\tdocument.body.appendChild( newNode );\n\n\t\t// Resolve Stylesheets and Inline JavaScript immediately.\n\t\tif (\n\t\t\t'link' === newNode.nodeName.toLowerCase() ||\n\t\t\t( 'script' === newNode.nodeName.toLowerCase() && ! newNode.src )\n\t\t) {\n\t\t\tresolve();\n\t\t}\n\t} );\n};\n\n/**\n * Load the asset files for a block\n */\nexport async function loadAssets() {\n\t/*\n\t * Fetch the current URL (post-new.php, or post.php?post=1&action=edit) and compare the\n\t * JavaScript and CSS assets loaded between the pages. This imports the required assets\n\t * for the block into the current page while not requiring that we know them up-front.\n\t * In the future this can be improved by reliance upon block.json and/or a script-loader\n\t * dependency API.\n\t */\n\tconst response = await apiFetch( {\n\t\turl: document.location.href,\n\t\tparse: false,\n\t} );\n\n\tconst data = await response.text();\n\n\tconst doc = new window.DOMParser().parseFromString( data, 'text/html' );\n\n\tconst newAssets = Array.from(\n\t\tdoc.querySelectorAll( 'link[rel=\"stylesheet\"],script' )\n\t).filter( ( asset ) => asset.id && ! document.getElementById( asset.id ) );\n\n\t/*\n\t * Load each asset in order, as they may depend upon an earlier loaded script.\n\t * Stylesheets and Inline Scripts will resolve immediately upon insertion.\n\t */\n\tfor ( const newAsset of newAssets ) {\n\t\tawait loadAsset( newAsset );\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAYA,MAAa,aAAc,OAAQ;CAClC,OAAO,IAAI,SAAW,SAAS,WAAY;EAK1C,MAAM,UAAU,SAAS,cAAe,GAAG,QAAS;EAEpD;GAAE;GAAM;GAAO;GAAO;GAAQ;EAAO,CAAC,CAAC,SAAW,SAAU;GAC3D,IAAK,GAAI,OACR,QAAS,QAAS,GAAI;EAExB,CAAE;EAGF,IAAK,GAAG,WACP,QAAQ,YAAa,SAAS,eAAgB,GAAG,SAAU,CAAE;EAG9D,QAAQ,eAAe,QAAS,IAAK;EACrC,QAAQ,gBAAgB,uBAAQ,IAAI,MAAO,sBAAuB,CAAE;EAEpE,SAAS,KAAK,YAAa,OAAQ;EAGnC,IACC,WAAW,QAAQ,SAAS,YAAY,KACtC,aAAa,QAAQ,SAAS,YAAY,KAAK,CAAE,QAAQ,KAE3D,QAAQ;CAEV,CAAE;AACH;;;;AAKA,eAAsB,aAAa;CAalC,MAAM,OAAO,OAAM,OAAA,GALIA,qBAAAA,QAAAA,CAAU;EAChC,KAAK,SAAS,SAAS;EACvB,OAAO;CACR,CAAE,EAAA,CAE0B,KAAK;CAEjC,MAAM,MAAM,IAAI,OAAO,UAAU,CAAC,CAAC,gBAAiB,MAAM,WAAY;CAEtE,MAAM,YAAY,MAAM,KACvB,IAAI,iBAAkB,iCAAgC,CACvD,CAAC,CAAC,QAAU,UAAW,MAAM,MAAM,CAAE,SAAS,eAAgB,MAAM,EAAG,CAAE;CAMzE,KAAM,MAAM,YAAY,WACvB,MAAM,UAAW,QAAS;AAE5B"}
@@ -1,107 +1,96 @@
1
- var __defProp = Object.defineProperty;
2
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
- var __getOwnPropNames = Object.getOwnPropertyNames;
4
- var __hasOwnProp = Object.prototype.hasOwnProperty;
5
- var __export = (target, all) => {
6
- for (var name in all)
7
- __defProp(target, name, { get: all[name], enumerable: true });
8
- };
9
- var __copyProps = (to, from, except, desc) => {
10
- if (from && typeof from === "object" || typeof from === "function") {
11
- for (let key of __getOwnPropNames(from))
12
- if (!__hasOwnProp.call(to, key) && key !== except)
13
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
- }
15
- return to;
16
- };
17
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
-
19
- // packages/block-directory/src/store/reducer.js
20
- var reducer_exports = {};
21
- __export(reducer_exports, {
22
- blockManagement: () => blockManagement,
23
- default: () => reducer_default,
24
- downloadableBlocks: () => downloadableBlocks,
25
- errorNotices: () => errorNotices
1
+ "use strict";
2
+ Object.defineProperties(exports, {
3
+ __esModule: { value: true },
4
+ [Symbol.toStringTag]: { value: "Module" }
26
5
  });
27
- module.exports = __toCommonJS(reducer_exports);
28
- var import_data = require("@wordpress/data");
29
- var downloadableBlocks = (state = {}, action) => {
30
- switch (action.type) {
31
- case "FETCH_DOWNLOADABLE_BLOCKS":
32
- return {
33
- ...state,
34
- [action.filterValue]: {
35
- isRequesting: true
36
- }
37
- };
38
- case "RECEIVE_DOWNLOADABLE_BLOCKS":
39
- return {
40
- ...state,
41
- [action.filterValue]: {
42
- results: action.downloadableBlocks,
43
- isRequesting: false
44
- }
45
- };
46
- }
47
- return state;
6
+ let _wordpress_data = require("@wordpress/data");
7
+ // packages/block-directory/src/store/reducer.js
8
+ /**
9
+ * Reducer returning an array of downloadable blocks.
10
+ *
11
+ * @param {Object} state Current state.
12
+ * @param {Object} action Dispatched action.
13
+ *
14
+ * @return {Object} Updated state.
15
+ */
16
+ const downloadableBlocks = (state = {}, action) => {
17
+ switch (action.type) {
18
+ case "FETCH_DOWNLOADABLE_BLOCKS": return {
19
+ ...state,
20
+ [action.filterValue]: { isRequesting: true }
21
+ };
22
+ case "RECEIVE_DOWNLOADABLE_BLOCKS": return {
23
+ ...state,
24
+ [action.filterValue]: {
25
+ results: action.downloadableBlocks,
26
+ isRequesting: false
27
+ }
28
+ };
29
+ }
30
+ return state;
48
31
  };
49
- var blockManagement = (state = {
50
- installedBlockTypes: [],
51
- isInstalling: {}
32
+ /**
33
+ * Reducer managing the installation and deletion of blocks.
34
+ *
35
+ * @param {Object} state Current state.
36
+ * @param {Object} action Dispatched action.
37
+ *
38
+ * @return {Object} Updated state.
39
+ */
40
+ const blockManagement = (state = {
41
+ installedBlockTypes: [],
42
+ isInstalling: {}
52
43
  }, action) => {
53
- switch (action.type) {
54
- case "ADD_INSTALLED_BLOCK_TYPE":
55
- return {
56
- ...state,
57
- installedBlockTypes: [
58
- ...state.installedBlockTypes,
59
- action.item
60
- ]
61
- };
62
- case "REMOVE_INSTALLED_BLOCK_TYPE":
63
- return {
64
- ...state,
65
- installedBlockTypes: state.installedBlockTypes.filter(
66
- (blockType) => blockType.name !== action.item.name
67
- )
68
- };
69
- case "SET_INSTALLING_BLOCK":
70
- return {
71
- ...state,
72
- isInstalling: {
73
- ...state.isInstalling,
74
- [action.blockId]: action.isInstalling
75
- }
76
- };
77
- }
78
- return state;
44
+ switch (action.type) {
45
+ case "ADD_INSTALLED_BLOCK_TYPE": return {
46
+ ...state,
47
+ installedBlockTypes: [...state.installedBlockTypes, action.item]
48
+ };
49
+ case "REMOVE_INSTALLED_BLOCK_TYPE": return {
50
+ ...state,
51
+ installedBlockTypes: state.installedBlockTypes.filter((blockType) => blockType.name !== action.item.name)
52
+ };
53
+ case "SET_INSTALLING_BLOCK": return {
54
+ ...state,
55
+ isInstalling: {
56
+ ...state.isInstalling,
57
+ [action.blockId]: action.isInstalling
58
+ }
59
+ };
60
+ }
61
+ return state;
79
62
  };
80
- var errorNotices = (state = {}, action) => {
81
- switch (action.type) {
82
- case "SET_ERROR_NOTICE":
83
- return {
84
- ...state,
85
- [action.blockId]: {
86
- message: action.message,
87
- isFatal: action.isFatal
88
- }
89
- };
90
- case "CLEAR_ERROR_NOTICE":
91
- const { [action.blockId]: blockId, ...restState } = state;
92
- return restState;
93
- }
94
- return state;
63
+ /**
64
+ * Reducer returning an object of error notices.
65
+ *
66
+ * @param {Object} state Current state.
67
+ * @param {Object} action Dispatched action.
68
+ *
69
+ * @return {Object} Updated state.
70
+ */
71
+ const errorNotices = (state = {}, action) => {
72
+ switch (action.type) {
73
+ case "SET_ERROR_NOTICE": return {
74
+ ...state,
75
+ [action.blockId]: {
76
+ message: action.message,
77
+ isFatal: action.isFatal
78
+ }
79
+ };
80
+ case "CLEAR_ERROR_NOTICE":
81
+ const { [action.blockId]: blockId, ...restState } = state;
82
+ return restState;
83
+ }
84
+ return state;
95
85
  };
96
- var reducer_default = (0, import_data.combineReducers)({
97
- downloadableBlocks,
98
- blockManagement,
99
- errorNotices
100
- });
101
- // Annotate the CommonJS export names for ESM import in node:
102
- 0 && (module.exports = {
103
- blockManagement,
104
- downloadableBlocks,
105
- errorNotices
86
+ var reducer_default = (0, _wordpress_data.combineReducers)({
87
+ downloadableBlocks,
88
+ blockManagement,
89
+ errorNotices
106
90
  });
107
- //# sourceMappingURL=reducer.cjs.map
91
+ exports.blockManagement = blockManagement;
92
+ exports.default = reducer_default;
93
+ exports.downloadableBlocks = downloadableBlocks;
94
+ exports.errorNotices = errorNotices;
95
+
96
+ //# sourceMappingURL=reducer.cjs.map
@@ -1,7 +1 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../src/store/reducer.js"],
4
- "sourcesContent": ["import { combineReducers } from '@wordpress/data';\n\n/**\n * Reducer returning an array of downloadable blocks.\n *\n * @param {Object} state Current state.\n * @param {Object} action Dispatched action.\n *\n * @return {Object} Updated state.\n */\nexport const downloadableBlocks = ( state = {}, action ) => {\n\tswitch ( action.type ) {\n\t\tcase 'FETCH_DOWNLOADABLE_BLOCKS':\n\t\t\treturn {\n\t\t\t\t...state,\n\t\t\t\t[ action.filterValue ]: {\n\t\t\t\t\tisRequesting: true,\n\t\t\t\t},\n\t\t\t};\n\t\tcase 'RECEIVE_DOWNLOADABLE_BLOCKS':\n\t\t\treturn {\n\t\t\t\t...state,\n\t\t\t\t[ action.filterValue ]: {\n\t\t\t\t\tresults: action.downloadableBlocks,\n\t\t\t\t\tisRequesting: false,\n\t\t\t\t},\n\t\t\t};\n\t}\n\treturn state;\n};\n\n/**\n * Reducer managing the installation and deletion of blocks.\n *\n * @param {Object} state Current state.\n * @param {Object} action Dispatched action.\n *\n * @return {Object} Updated state.\n */\nexport const blockManagement = (\n\tstate = {\n\t\tinstalledBlockTypes: [],\n\t\tisInstalling: {},\n\t},\n\taction\n) => {\n\tswitch ( action.type ) {\n\t\tcase 'ADD_INSTALLED_BLOCK_TYPE':\n\t\t\treturn {\n\t\t\t\t...state,\n\t\t\t\tinstalledBlockTypes: [\n\t\t\t\t\t...state.installedBlockTypes,\n\t\t\t\t\taction.item,\n\t\t\t\t],\n\t\t\t};\n\t\tcase 'REMOVE_INSTALLED_BLOCK_TYPE':\n\t\t\treturn {\n\t\t\t\t...state,\n\t\t\t\tinstalledBlockTypes: state.installedBlockTypes.filter(\n\t\t\t\t\t( blockType ) => blockType.name !== action.item.name\n\t\t\t\t),\n\t\t\t};\n\t\tcase 'SET_INSTALLING_BLOCK':\n\t\t\treturn {\n\t\t\t\t...state,\n\t\t\t\tisInstalling: {\n\t\t\t\t\t...state.isInstalling,\n\t\t\t\t\t[ action.blockId ]: action.isInstalling,\n\t\t\t\t},\n\t\t\t};\n\t}\n\treturn state;\n};\n\n/**\n * Reducer returning an object of error notices.\n *\n * @param {Object} state Current state.\n * @param {Object} action Dispatched action.\n *\n * @return {Object} Updated state.\n */\nexport const errorNotices = ( state = {}, action ) => {\n\tswitch ( action.type ) {\n\t\tcase 'SET_ERROR_NOTICE':\n\t\t\treturn {\n\t\t\t\t...state,\n\t\t\t\t[ action.blockId ]: {\n\t\t\t\t\tmessage: action.message,\n\t\t\t\t\tisFatal: action.isFatal,\n\t\t\t\t},\n\t\t\t};\n\t\tcase 'CLEAR_ERROR_NOTICE':\n\t\t\tconst { [ action.blockId ]: blockId, ...restState } = state;\n\t\t\treturn restState;\n\t}\n\treturn state;\n};\n\nexport default combineReducers( {\n\tdownloadableBlocks,\n\tblockManagement,\n\terrorNotices,\n} );\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAAgC;AAUzB,IAAM,qBAAqB,CAAE,QAAQ,CAAC,GAAG,WAAY;AAC3D,UAAS,OAAO,MAAO;AAAA,IACtB,KAAK;AACJ,aAAO;AAAA,QACN,GAAG;AAAA,QACH,CAAE,OAAO,WAAY,GAAG;AAAA,UACvB,cAAc;AAAA,QACf;AAAA,MACD;AAAA,IACD,KAAK;AACJ,aAAO;AAAA,QACN,GAAG;AAAA,QACH,CAAE,OAAO,WAAY,GAAG;AAAA,UACvB,SAAS,OAAO;AAAA,UAChB,cAAc;AAAA,QACf;AAAA,MACD;AAAA,EACF;AACA,SAAO;AACR;AAUO,IAAM,kBAAkB,CAC9B,QAAQ;AAAA,EACP,qBAAqB,CAAC;AAAA,EACtB,cAAc,CAAC;AAChB,GACA,WACI;AACJ,UAAS,OAAO,MAAO;AAAA,IACtB,KAAK;AACJ,aAAO;AAAA,QACN,GAAG;AAAA,QACH,qBAAqB;AAAA,UACpB,GAAG,MAAM;AAAA,UACT,OAAO;AAAA,QACR;AAAA,MACD;AAAA,IACD,KAAK;AACJ,aAAO;AAAA,QACN,GAAG;AAAA,QACH,qBAAqB,MAAM,oBAAoB;AAAA,UAC9C,CAAE,cAAe,UAAU,SAAS,OAAO,KAAK;AAAA,QACjD;AAAA,MACD;AAAA,IACD,KAAK;AACJ,aAAO;AAAA,QACN,GAAG;AAAA,QACH,cAAc;AAAA,UACb,GAAG,MAAM;AAAA,UACT,CAAE,OAAO,OAAQ,GAAG,OAAO;AAAA,QAC5B;AAAA,MACD;AAAA,EACF;AACA,SAAO;AACR;AAUO,IAAM,eAAe,CAAE,QAAQ,CAAC,GAAG,WAAY;AACrD,UAAS,OAAO,MAAO;AAAA,IACtB,KAAK;AACJ,aAAO;AAAA,QACN,GAAG;AAAA,QACH,CAAE,OAAO,OAAQ,GAAG;AAAA,UACnB,SAAS,OAAO;AAAA,UAChB,SAAS,OAAO;AAAA,QACjB;AAAA,MACD;AAAA,IACD,KAAK;AACJ,YAAM,EAAE,CAAE,OAAO,OAAQ,GAAG,SAAS,GAAG,UAAU,IAAI;AACtD,aAAO;AAAA,EACT;AACA,SAAO;AACR;AAEA,IAAO,sBAAQ,6BAAiB;AAAA,EAC/B;AAAA,EACA;AAAA,EACA;AACD,CAAE;",
6
- "names": []
7
- }
1
+ {"version":3,"file":"reducer.cjs","names":["combineReducers"],"sources":["../../src/store/reducer.js"],"sourcesContent":["import { combineReducers } from '@wordpress/data';\n\n/**\n * Reducer returning an array of downloadable blocks.\n *\n * @param {Object} state Current state.\n * @param {Object} action Dispatched action.\n *\n * @return {Object} Updated state.\n */\nexport const downloadableBlocks = ( state = {}, action ) => {\n\tswitch ( action.type ) {\n\t\tcase 'FETCH_DOWNLOADABLE_BLOCKS':\n\t\t\treturn {\n\t\t\t\t...state,\n\t\t\t\t[ action.filterValue ]: {\n\t\t\t\t\tisRequesting: true,\n\t\t\t\t},\n\t\t\t};\n\t\tcase 'RECEIVE_DOWNLOADABLE_BLOCKS':\n\t\t\treturn {\n\t\t\t\t...state,\n\t\t\t\t[ action.filterValue ]: {\n\t\t\t\t\tresults: action.downloadableBlocks,\n\t\t\t\t\tisRequesting: false,\n\t\t\t\t},\n\t\t\t};\n\t}\n\treturn state;\n};\n\n/**\n * Reducer managing the installation and deletion of blocks.\n *\n * @param {Object} state Current state.\n * @param {Object} action Dispatched action.\n *\n * @return {Object} Updated state.\n */\nexport const blockManagement = (\n\tstate = {\n\t\tinstalledBlockTypes: [],\n\t\tisInstalling: {},\n\t},\n\taction\n) => {\n\tswitch ( action.type ) {\n\t\tcase 'ADD_INSTALLED_BLOCK_TYPE':\n\t\t\treturn {\n\t\t\t\t...state,\n\t\t\t\tinstalledBlockTypes: [\n\t\t\t\t\t...state.installedBlockTypes,\n\t\t\t\t\taction.item,\n\t\t\t\t],\n\t\t\t};\n\t\tcase 'REMOVE_INSTALLED_BLOCK_TYPE':\n\t\t\treturn {\n\t\t\t\t...state,\n\t\t\t\tinstalledBlockTypes: state.installedBlockTypes.filter(\n\t\t\t\t\t( blockType ) => blockType.name !== action.item.name\n\t\t\t\t),\n\t\t\t};\n\t\tcase 'SET_INSTALLING_BLOCK':\n\t\t\treturn {\n\t\t\t\t...state,\n\t\t\t\tisInstalling: {\n\t\t\t\t\t...state.isInstalling,\n\t\t\t\t\t[ action.blockId ]: action.isInstalling,\n\t\t\t\t},\n\t\t\t};\n\t}\n\treturn state;\n};\n\n/**\n * Reducer returning an object of error notices.\n *\n * @param {Object} state Current state.\n * @param {Object} action Dispatched action.\n *\n * @return {Object} Updated state.\n */\nexport const errorNotices = ( state = {}, action ) => {\n\tswitch ( action.type ) {\n\t\tcase 'SET_ERROR_NOTICE':\n\t\t\treturn {\n\t\t\t\t...state,\n\t\t\t\t[ action.blockId ]: {\n\t\t\t\t\tmessage: action.message,\n\t\t\t\t\tisFatal: action.isFatal,\n\t\t\t\t},\n\t\t\t};\n\t\tcase 'CLEAR_ERROR_NOTICE':\n\t\t\tconst { [ action.blockId ]: blockId, ...restState } = state;\n\t\t\treturn restState;\n\t}\n\treturn state;\n};\n\nexport default combineReducers( {\n\tdownloadableBlocks,\n\tblockManagement,\n\terrorNotices,\n} );\n"],"mappings":";;;;;;;;;;;;;;;AAUA,MAAa,sBAAuB,QAAQ,CAAC,GAAG,WAAY;CAC3D,QAAS,OAAO,MAAhB;EACC,KAAK,6BACJ,OAAO;GACN,GAAG;IACD,OAAO,cAAe,EACvB,cAAc,KACf;EACD;EACD,KAAK,+BACJ,OAAO;GACN,GAAG;IACD,OAAO,cAAe;IACvB,SAAS,OAAO;IAChB,cAAc;GACf;EACD;CACF;CACA,OAAO;AACR;;;;;;;;;AAUA,MAAa,mBACZ,QAAQ;CACP,qBAAqB,CAAC;CACtB,cAAc,CAAC;AAChB,GACA,WACI;CACJ,QAAS,OAAO,MAAhB;EACC,KAAK,4BACJ,OAAO;GACN,GAAG;GACH,qBAAqB,CACpB,GAAG,MAAM,qBACT,OAAO,IACR;EACD;EACD,KAAK,+BACJ,OAAO;GACN,GAAG;GACH,qBAAqB,MAAM,oBAAoB,QAC5C,cAAe,UAAU,SAAS,OAAO,KAAK,IACjD;EACD;EACD,KAAK,wBACJ,OAAO;GACN,GAAG;GACH,cAAc;IACb,GAAG,MAAM;KACP,OAAO,UAAW,OAAO;GAC5B;EACD;CACF;CACA,OAAO;AACR;;;;;;;;;AAUA,MAAa,gBAAiB,QAAQ,CAAC,GAAG,WAAY;CACrD,QAAS,OAAO,MAAhB;EACC,KAAK,oBACJ,OAAO;GACN,GAAG;IACD,OAAO,UAAW;IACnB,SAAS,OAAO;IAChB,SAAS,OAAO;GACjB;EACD;EACD,KAAK;GACJ,MAAM,GAAI,OAAO,UAAW,SAAS,GAAG,cAAc;GACtD,OAAO;CACT;CACA,OAAO;AACR;AAEA,IAAA,mBAAA,GAAeA,gBAAAA,gBAAAA,CAAiB;CAC/B;CACA;CACA;AACD,CAAE"}