@wordpress/block-directory 5.57.0 → 6.1.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 (109) 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 +23 -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 -39
  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 +15 -20
  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 +51 -90
  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 +21 -18
  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 +25 -27
  98. package/src/components/downloadable-block-list-item/index.jsx +2 -2
  99. package/src/components/downloadable-block-list-item/style.scss +6 -6
  100. package/src/components/downloadable-blocks-panel/index.jsx +2 -2
  101. package/src/components/downloadable-blocks-panel/no-results.jsx +15 -8
  102. package/CHANGELOG.md +0 -295
  103. package/build/index.cjs.map +0 -7
  104. package/build/lock-unlock.cjs +0 -36
  105. package/build/lock-unlock.cjs.map +0 -7
  106. package/build-module/index.mjs.map +0 -7
  107. package/build-module/lock-unlock.mjs +0 -11
  108. package/build-module/lock-unlock.mjs.map +0 -7
  109. package/src/lock-unlock.js +0 -7
@@ -1,64 +1,44 @@
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 change_case = require("change-case");
28
+ let _wordpress_api_fetch = require("@wordpress/api-fetch");
29
+ _wordpress_api_fetch = __toESM(_wordpress_api_fetch);
30
+ let __actions_js = require("./actions.cjs");
29
31
  // packages/block-directory/src/store/resolvers.js
30
- var resolvers_exports = {};
31
- __export(resolvers_exports, {
32
- getDownloadableBlocks: () => getDownloadableBlocks
33
- });
34
- module.exports = __toCommonJS(resolvers_exports);
35
- var import_change_case = require("change-case");
36
- var import_api_fetch = __toESM(require("@wordpress/api-fetch"));
37
- var import_actions = require("./actions.cjs");
38
- var getDownloadableBlocks = (filterValue) => async ({ dispatch }) => {
39
- if (!filterValue) {
40
- return;
41
- }
42
- try {
43
- dispatch((0, import_actions.fetchDownloadableBlocks)(filterValue));
44
- const results = await (0, import_api_fetch.default)({
45
- path: `wp/v2/block-directory/search?term=${filterValue}`
46
- });
47
- const blocks = results.map(
48
- (result) => Object.fromEntries(
49
- Object.entries(result).map(([key, value]) => [
50
- (0, import_change_case.camelCase)(key),
51
- value
52
- ])
53
- )
54
- );
55
- dispatch((0, import_actions.receiveDownloadableBlocks)(blocks, filterValue));
56
- } catch {
57
- dispatch((0, import_actions.receiveDownloadableBlocks)([], filterValue));
58
- }
32
+ const getDownloadableBlocks = (filterValue) => async ({ dispatch }) => {
33
+ if (!filterValue) return;
34
+ try {
35
+ dispatch((0, __actions_js.fetchDownloadableBlocks)(filterValue));
36
+ const blocks = (await (0, _wordpress_api_fetch.default)({ path: `wp/v2/block-directory/search?term=${filterValue}` })).map((result) => Object.fromEntries(Object.entries(result).map(([key, value]) => [(0, change_case.camelCase)(key), value])));
37
+ dispatch((0, __actions_js.receiveDownloadableBlocks)(blocks, filterValue));
38
+ } catch {
39
+ dispatch((0, __actions_js.receiveDownloadableBlocks)([], filterValue));
40
+ }
59
41
  };
60
- // Annotate the CommonJS export names for ESM import in node:
61
- 0 && (module.exports = {
62
- getDownloadableBlocks
63
- });
64
- //# sourceMappingURL=resolvers.cjs.map
42
+ exports.getDownloadableBlocks = getDownloadableBlocks;
43
+
44
+ //# sourceMappingURL=resolvers.cjs.map
@@ -1,7 +1 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../src/store/resolvers.js"],
4
- "sourcesContent": ["import { camelCase } from 'change-case';\nimport apiFetch from '@wordpress/api-fetch';\nimport { fetchDownloadableBlocks, receiveDownloadableBlocks } from './actions';\n\nexport const getDownloadableBlocks =\n\t( filterValue ) =>\n\tasync ( { dispatch } ) => {\n\t\tif ( ! filterValue ) {\n\t\t\treturn;\n\t\t}\n\n\t\ttry {\n\t\t\tdispatch( fetchDownloadableBlocks( filterValue ) );\n\t\t\tconst results = await apiFetch( {\n\t\t\t\tpath: `wp/v2/block-directory/search?term=${ filterValue }`,\n\t\t\t} );\n\t\t\tconst blocks = results.map( ( result ) =>\n\t\t\t\tObject.fromEntries(\n\t\t\t\t\tObject.entries( result ).map( ( [ key, value ] ) => [\n\t\t\t\t\t\tcamelCase( key ),\n\t\t\t\t\t\tvalue,\n\t\t\t\t\t] )\n\t\t\t\t)\n\t\t\t);\n\n\t\t\tdispatch( receiveDownloadableBlocks( blocks, filterValue ) );\n\t\t} catch {\n\t\t\tdispatch( receiveDownloadableBlocks( [], filterValue ) );\n\t\t}\n\t};\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,yBAA0B;AAC1B,uBAAqB;AACrB,qBAAmE;AAE5D,IAAM,wBACZ,CAAE,gBACF,OAAQ,EAAE,SAAS,MAAO;AACzB,MAAK,CAAE,aAAc;AACpB;AAAA,EACD;AAEA,MAAI;AACH,iBAAU,wCAAyB,WAAY,CAAE;AACjD,UAAM,UAAU,UAAM,iBAAAA,SAAU;AAAA,MAC/B,MAAM,qCAAsC,WAAY;AAAA,IACzD,CAAE;AACF,UAAM,SAAS,QAAQ;AAAA,MAAK,CAAE,WAC7B,OAAO;AAAA,QACN,OAAO,QAAS,MAAO,EAAE,IAAK,CAAE,CAAE,KAAK,KAAM,MAAO;AAAA,cACnD,8BAAW,GAAI;AAAA,UACf;AAAA,QACD,CAAE;AAAA,MACH;AAAA,IACD;AAEA,iBAAU,0CAA2B,QAAQ,WAAY,CAAE;AAAA,EAC5D,QAAQ;AACP,iBAAU,0CAA2B,CAAC,GAAG,WAAY,CAAE;AAAA,EACxD;AACD;",
6
- "names": ["apiFetch"]
7
- }
1
+ {"version":3,"file":"resolvers.cjs","names":["fetchDownloadableBlocks","apiFetch","camelCase","receiveDownloadableBlocks"],"sources":["../../src/store/resolvers.js"],"sourcesContent":["import { camelCase } from 'change-case';\nimport apiFetch from '@wordpress/api-fetch';\nimport { fetchDownloadableBlocks, receiveDownloadableBlocks } from './actions';\n\nexport const getDownloadableBlocks =\n\t( filterValue ) =>\n\tasync ( { dispatch } ) => {\n\t\tif ( ! filterValue ) {\n\t\t\treturn;\n\t\t}\n\n\t\ttry {\n\t\t\tdispatch( fetchDownloadableBlocks( filterValue ) );\n\t\t\tconst results = await apiFetch( {\n\t\t\t\tpath: `wp/v2/block-directory/search?term=${ filterValue }`,\n\t\t\t} );\n\t\t\tconst blocks = results.map( ( result ) =>\n\t\t\t\tObject.fromEntries(\n\t\t\t\t\tObject.entries( result ).map( ( [ key, value ] ) => [\n\t\t\t\t\t\tcamelCase( key ),\n\t\t\t\t\t\tvalue,\n\t\t\t\t\t] )\n\t\t\t\t)\n\t\t\t);\n\n\t\t\tdispatch( receiveDownloadableBlocks( blocks, filterValue ) );\n\t\t} catch {\n\t\t\tdispatch( receiveDownloadableBlocks( [], filterValue ) );\n\t\t}\n\t};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAIA,MAAa,yBACV,gBACF,OAAQ,EAAE,eAAgB;CACzB,IAAK,CAAE,aACN;CAGD,IAAI;EACH,UAAA,GAAUA,aAAAA,wBAAAA,CAAyB,WAAY,CAAE;EAIjD,MAAM,UAAS,OAAA,GAHOC,qBAAAA,QAAAA,CAAU,EAC/B,MAAM,qCAAsC,cAC7C,CAAE,EAAA,CACqB,KAAO,WAC7B,OAAO,YACN,OAAO,QAAS,MAAO,CAAC,CAAC,KAAO,CAAE,KAAK,WAAa,EAAA,GACnDC,YAAAA,UAAAA,CAAW,GAAI,GACf,KACD,CAAE,CACH,CACD;EAEA,UAAA,GAAUC,aAAAA,0BAAAA,CAA2B,QAAQ,WAAY,CAAE;CAC5D,QAAQ;EACP,UAAA,GAAUA,aAAAA,0BAAAA,CAA2B,CAAC,GAAG,WAAY,CAAE;CACxD;AACD"}
@@ -1,120 +1,124 @@
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/selectors.js
20
- var selectors_exports = {};
21
- __export(selectors_exports, {
22
- getDownloadableBlocks: () => getDownloadableBlocks,
23
- getErrorNoticeForBlock: () => getErrorNoticeForBlock,
24
- getErrorNotices: () => getErrorNotices,
25
- getInstalledBlockTypes: () => getInstalledBlockTypes,
26
- getNewBlockTypes: () => getNewBlockTypes,
27
- getUnusedBlockTypes: () => getUnusedBlockTypes,
28
- isInstalling: () => isInstalling,
29
- isRequestingDownloadableBlocks: () => isRequestingDownloadableBlocks
1
+ "use strict";
2
+ Object.defineProperties(exports, {
3
+ __esModule: { value: true },
4
+ [Symbol.toStringTag]: { value: "Module" }
30
5
  });
31
- module.exports = __toCommonJS(selectors_exports);
32
- var import_data = require("@wordpress/data");
33
- var import_block_editor = require("@wordpress/block-editor");
34
- var EMPTY_ARRAY = [];
6
+ let _wordpress_data = require("@wordpress/data");
7
+ let _wordpress_block_editor = require("@wordpress/block-editor");
8
+ // packages/block-directory/src/store/selectors.js
9
+ const EMPTY_ARRAY = [];
10
+ /**
11
+ * Returns true if application is requesting for downloadable blocks.
12
+ *
13
+ * @param {Object} state Global application state.
14
+ * @param {string} filterValue Search string.
15
+ *
16
+ * @return {boolean} Whether a request is in progress for the blocks list.
17
+ */
35
18
  function isRequestingDownloadableBlocks(state, filterValue) {
36
- return state.downloadableBlocks[filterValue]?.isRequesting ?? false;
19
+ return state.downloadableBlocks[filterValue]?.isRequesting ?? false;
37
20
  }
21
+ /**
22
+ * Returns the available uninstalled blocks.
23
+ *
24
+ * @param {Object} state Global application state.
25
+ * @param {string} filterValue Search string.
26
+ *
27
+ * @return {Array} Downloadable blocks.
28
+ */
38
29
  function getDownloadableBlocks(state, filterValue) {
39
- return state.downloadableBlocks[filterValue]?.results ?? EMPTY_ARRAY;
30
+ return state.downloadableBlocks[filterValue]?.results ?? EMPTY_ARRAY;
40
31
  }
32
+ /**
33
+ * Returns the block types that have been installed on the server in this
34
+ * session.
35
+ *
36
+ * @param {Object} state Global application state.
37
+ *
38
+ * @return {Array} Block type items
39
+ */
41
40
  function getInstalledBlockTypes(state) {
42
- return state.blockManagement.installedBlockTypes;
41
+ return state.blockManagement.installedBlockTypes;
43
42
  }
44
- var getNewBlockTypes = (0, import_data.createRegistrySelector)(
45
- (select) => (0, import_data.createSelector)(
46
- (state) => {
47
- const installedBlockTypes = getInstalledBlockTypes(state);
48
- if (!installedBlockTypes.length) {
49
- return EMPTY_ARRAY;
50
- }
51
- const { getBlockName, getClientIdsWithDescendants } = select(import_block_editor.store);
52
- const installedBlockNames = installedBlockTypes.map(
53
- (blockType) => blockType.name
54
- );
55
- const foundBlockNames = getClientIdsWithDescendants().flatMap(
56
- (clientId) => {
57
- const blockName = getBlockName(clientId);
58
- return installedBlockNames.includes(blockName) ? blockName : [];
59
- }
60
- );
61
- const newBlockTypes = installedBlockTypes.filter(
62
- (blockType) => foundBlockNames.includes(blockType.name)
63
- );
64
- return newBlockTypes.length > 0 ? newBlockTypes : EMPTY_ARRAY;
65
- },
66
- (state) => [
67
- getInstalledBlockTypes(state),
68
- select(import_block_editor.store).getClientIdsWithDescendants()
69
- ]
70
- )
71
- );
72
- var getUnusedBlockTypes = (0, import_data.createRegistrySelector)(
73
- (select) => (0, import_data.createSelector)(
74
- (state) => {
75
- const installedBlockTypes = getInstalledBlockTypes(state);
76
- if (!installedBlockTypes.length) {
77
- return EMPTY_ARRAY;
78
- }
79
- const { getBlockName, getClientIdsWithDescendants } = select(import_block_editor.store);
80
- const installedBlockNames = installedBlockTypes.map(
81
- (blockType) => blockType.name
82
- );
83
- const foundBlockNames = getClientIdsWithDescendants().flatMap(
84
- (clientId) => {
85
- const blockName = getBlockName(clientId);
86
- return installedBlockNames.includes(blockName) ? blockName : [];
87
- }
88
- );
89
- const unusedBlockTypes = installedBlockTypes.filter(
90
- (blockType) => !foundBlockNames.includes(blockType.name)
91
- );
92
- return unusedBlockTypes.length > 0 ? unusedBlockTypes : EMPTY_ARRAY;
93
- },
94
- (state) => [
95
- getInstalledBlockTypes(state),
96
- select(import_block_editor.store).getClientIdsWithDescendants()
97
- ]
98
- )
99
- );
43
+ /**
44
+ * Returns block types that have been installed on the server and used in the
45
+ * current post.
46
+ *
47
+ * @param {Object} state Global application state.
48
+ *
49
+ * @return {Array} Block type items.
50
+ */
51
+ const getNewBlockTypes = (0, _wordpress_data.createRegistrySelector)((select) => (0, _wordpress_data.createSelector)((state) => {
52
+ const installedBlockTypes = getInstalledBlockTypes(state);
53
+ if (!installedBlockTypes.length) return EMPTY_ARRAY;
54
+ const { getBlockName, getClientIdsWithDescendants } = select(_wordpress_block_editor.store);
55
+ const installedBlockNames = installedBlockTypes.map((blockType) => blockType.name);
56
+ const foundBlockNames = getClientIdsWithDescendants().flatMap((clientId) => {
57
+ const blockName = getBlockName(clientId);
58
+ return installedBlockNames.includes(blockName) ? blockName : [];
59
+ });
60
+ const newBlockTypes = installedBlockTypes.filter((blockType) => foundBlockNames.includes(blockType.name));
61
+ return newBlockTypes.length > 0 ? newBlockTypes : EMPTY_ARRAY;
62
+ }, (state) => [getInstalledBlockTypes(state), select(_wordpress_block_editor.store).getClientIdsWithDescendants()]));
63
+ /**
64
+ * Returns the block types that have been installed on the server but are not
65
+ * used in the current post.
66
+ *
67
+ * @param {Object} state Global application state.
68
+ *
69
+ * @return {Array} Block type items.
70
+ */
71
+ const getUnusedBlockTypes = (0, _wordpress_data.createRegistrySelector)((select) => (0, _wordpress_data.createSelector)((state) => {
72
+ const installedBlockTypes = getInstalledBlockTypes(state);
73
+ if (!installedBlockTypes.length) return EMPTY_ARRAY;
74
+ const { getBlockName, getClientIdsWithDescendants } = select(_wordpress_block_editor.store);
75
+ const installedBlockNames = installedBlockTypes.map((blockType) => blockType.name);
76
+ const foundBlockNames = getClientIdsWithDescendants().flatMap((clientId) => {
77
+ const blockName = getBlockName(clientId);
78
+ return installedBlockNames.includes(blockName) ? blockName : [];
79
+ });
80
+ const unusedBlockTypes = installedBlockTypes.filter((blockType) => !foundBlockNames.includes(blockType.name));
81
+ return unusedBlockTypes.length > 0 ? unusedBlockTypes : EMPTY_ARRAY;
82
+ }, (state) => [getInstalledBlockTypes(state), select(_wordpress_block_editor.store).getClientIdsWithDescendants()]));
83
+ /**
84
+ * Returns true if a block plugin install is in progress.
85
+ *
86
+ * @param {Object} state Global application state.
87
+ * @param {string} blockId Id of the block.
88
+ *
89
+ * @return {boolean} Whether this block is currently being installed.
90
+ */
100
91
  function isInstalling(state, blockId) {
101
- return state.blockManagement.isInstalling[blockId] || false;
92
+ return state.blockManagement.isInstalling[blockId] || false;
102
93
  }
94
+ /**
95
+ * Returns all block error notices.
96
+ *
97
+ * @param {Object} state Global application state.
98
+ *
99
+ * @return {Object} Object with error notices.
100
+ */
103
101
  function getErrorNotices(state) {
104
- return state.errorNotices;
102
+ return state.errorNotices;
105
103
  }
104
+ /**
105
+ * Returns the error notice for a given block.
106
+ *
107
+ * @param {Object} state Global application state.
108
+ * @param {string} blockId The ID of the block plugin. eg: my-block
109
+ *
110
+ * @return {string|boolean} The error text, or false if no error.
111
+ */
106
112
  function getErrorNoticeForBlock(state, blockId) {
107
- return state.errorNotices[blockId];
113
+ return state.errorNotices[blockId];
108
114
  }
109
- // Annotate the CommonJS export names for ESM import in node:
110
- 0 && (module.exports = {
111
- getDownloadableBlocks,
112
- getErrorNoticeForBlock,
113
- getErrorNotices,
114
- getInstalledBlockTypes,
115
- getNewBlockTypes,
116
- getUnusedBlockTypes,
117
- isInstalling,
118
- isRequestingDownloadableBlocks
119
- });
120
- //# sourceMappingURL=selectors.cjs.map
115
+ exports.getDownloadableBlocks = getDownloadableBlocks;
116
+ exports.getErrorNoticeForBlock = getErrorNoticeForBlock;
117
+ exports.getErrorNotices = getErrorNotices;
118
+ exports.getInstalledBlockTypes = getInstalledBlockTypes;
119
+ exports.getNewBlockTypes = getNewBlockTypes;
120
+ exports.getUnusedBlockTypes = getUnusedBlockTypes;
121
+ exports.isInstalling = isInstalling;
122
+ exports.isRequestingDownloadableBlocks = isRequestingDownloadableBlocks;
123
+
124
+ //# sourceMappingURL=selectors.cjs.map
@@ -1,7 +1 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../src/store/selectors.js"],
4
- "sourcesContent": ["import { createSelector, createRegistrySelector } from '@wordpress/data';\nimport { store as blockEditorStore } from '@wordpress/block-editor';\n\nconst EMPTY_ARRAY = [];\n\n/**\n * Returns true if application is requesting for downloadable blocks.\n *\n * @param {Object} state Global application state.\n * @param {string} filterValue Search string.\n *\n * @return {boolean} Whether a request is in progress for the blocks list.\n */\nexport function isRequestingDownloadableBlocks( state, filterValue ) {\n\treturn state.downloadableBlocks[ filterValue ]?.isRequesting ?? false;\n}\n\n/**\n * Returns the available uninstalled blocks.\n *\n * @param {Object} state Global application state.\n * @param {string} filterValue Search string.\n *\n * @return {Array} Downloadable blocks.\n */\nexport function getDownloadableBlocks( state, filterValue ) {\n\treturn state.downloadableBlocks[ filterValue ]?.results ?? EMPTY_ARRAY;\n}\n\n/**\n * Returns the block types that have been installed on the server in this\n * session.\n *\n * @param {Object} state Global application state.\n *\n * @return {Array} Block type items\n */\nexport function getInstalledBlockTypes( state ) {\n\treturn state.blockManagement.installedBlockTypes;\n}\n\n/**\n * Returns block types that have been installed on the server and used in the\n * current post.\n *\n * @param {Object} state Global application state.\n *\n * @return {Array} Block type items.\n */\nexport const getNewBlockTypes = createRegistrySelector( ( select ) =>\n\tcreateSelector(\n\t\t( state ) => {\n\t\t\tconst installedBlockTypes = getInstalledBlockTypes( state );\n\t\t\tif ( ! installedBlockTypes.length ) {\n\t\t\t\treturn EMPTY_ARRAY;\n\t\t\t}\n\n\t\t\tconst { getBlockName, getClientIdsWithDescendants } =\n\t\t\t\tselect( blockEditorStore );\n\t\t\tconst installedBlockNames = installedBlockTypes.map(\n\t\t\t\t( blockType ) => blockType.name\n\t\t\t);\n\t\t\tconst foundBlockNames = getClientIdsWithDescendants().flatMap(\n\t\t\t\t( clientId ) => {\n\t\t\t\t\tconst blockName = getBlockName( clientId );\n\t\t\t\t\treturn installedBlockNames.includes( blockName )\n\t\t\t\t\t\t? blockName\n\t\t\t\t\t\t: [];\n\t\t\t\t}\n\t\t\t);\n\t\t\tconst newBlockTypes = installedBlockTypes.filter( ( blockType ) =>\n\t\t\t\tfoundBlockNames.includes( blockType.name )\n\t\t\t);\n\n\t\t\treturn newBlockTypes.length > 0 ? newBlockTypes : EMPTY_ARRAY;\n\t\t},\n\t\t( state ) => [\n\t\t\tgetInstalledBlockTypes( state ),\n\t\t\tselect( blockEditorStore ).getClientIdsWithDescendants(),\n\t\t]\n\t)\n);\n\n/**\n * Returns the block types that have been installed on the server but are not\n * used in the current post.\n *\n * @param {Object} state Global application state.\n *\n * @return {Array} Block type items.\n */\nexport const getUnusedBlockTypes = createRegistrySelector( ( select ) =>\n\tcreateSelector(\n\t\t( state ) => {\n\t\t\tconst installedBlockTypes = getInstalledBlockTypes( state );\n\t\t\tif ( ! installedBlockTypes.length ) {\n\t\t\t\treturn EMPTY_ARRAY;\n\t\t\t}\n\n\t\t\tconst { getBlockName, getClientIdsWithDescendants } =\n\t\t\t\tselect( blockEditorStore );\n\t\t\tconst installedBlockNames = installedBlockTypes.map(\n\t\t\t\t( blockType ) => blockType.name\n\t\t\t);\n\t\t\tconst foundBlockNames = getClientIdsWithDescendants().flatMap(\n\t\t\t\t( clientId ) => {\n\t\t\t\t\tconst blockName = getBlockName( clientId );\n\t\t\t\t\treturn installedBlockNames.includes( blockName )\n\t\t\t\t\t\t? blockName\n\t\t\t\t\t\t: [];\n\t\t\t\t}\n\t\t\t);\n\t\t\tconst unusedBlockTypes = installedBlockTypes.filter(\n\t\t\t\t( blockType ) => ! foundBlockNames.includes( blockType.name )\n\t\t\t);\n\n\t\t\treturn unusedBlockTypes.length > 0 ? unusedBlockTypes : EMPTY_ARRAY;\n\t\t},\n\t\t( state ) => [\n\t\t\tgetInstalledBlockTypes( state ),\n\t\t\tselect( blockEditorStore ).getClientIdsWithDescendants(),\n\t\t]\n\t)\n);\n\n/**\n * Returns true if a block plugin install is in progress.\n *\n * @param {Object} state Global application state.\n * @param {string} blockId Id of the block.\n *\n * @return {boolean} Whether this block is currently being installed.\n */\nexport function isInstalling( state, blockId ) {\n\treturn state.blockManagement.isInstalling[ blockId ] || false;\n}\n\n/**\n * Returns all block error notices.\n *\n * @param {Object} state Global application state.\n *\n * @return {Object} Object with error notices.\n */\nexport function getErrorNotices( state ) {\n\treturn state.errorNotices;\n}\n\n/**\n * Returns the error notice for a given block.\n *\n * @param {Object} state Global application state.\n * @param {string} blockId The ID of the block plugin. eg: my-block\n *\n * @return {string|boolean} The error text, or false if no error.\n */\nexport function getErrorNoticeForBlock( state, blockId ) {\n\treturn state.errorNotices[ blockId ];\n}\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAAuD;AACvD,0BAA0C;AAE1C,IAAM,cAAc,CAAC;AAUd,SAAS,+BAAgC,OAAO,aAAc;AACpE,SAAO,MAAM,mBAAoB,WAAY,GAAG,gBAAgB;AACjE;AAUO,SAAS,sBAAuB,OAAO,aAAc;AAC3D,SAAO,MAAM,mBAAoB,WAAY,GAAG,WAAW;AAC5D;AAUO,SAAS,uBAAwB,OAAQ;AAC/C,SAAO,MAAM,gBAAgB;AAC9B;AAUO,IAAM,uBAAmB;AAAA,EAAwB,CAAE,eACzD;AAAA,IACC,CAAE,UAAW;AACZ,YAAM,sBAAsB,uBAAwB,KAAM;AAC1D,UAAK,CAAE,oBAAoB,QAAS;AACnC,eAAO;AAAA,MACR;AAEA,YAAM,EAAE,cAAc,4BAA4B,IACjD,OAAQ,oBAAAA,KAAiB;AAC1B,YAAM,sBAAsB,oBAAoB;AAAA,QAC/C,CAAE,cAAe,UAAU;AAAA,MAC5B;AACA,YAAM,kBAAkB,4BAA4B,EAAE;AAAA,QACrD,CAAE,aAAc;AACf,gBAAM,YAAY,aAAc,QAAS;AACzC,iBAAO,oBAAoB,SAAU,SAAU,IAC5C,YACA,CAAC;AAAA,QACL;AAAA,MACD;AACA,YAAM,gBAAgB,oBAAoB;AAAA,QAAQ,CAAE,cACnD,gBAAgB,SAAU,UAAU,IAAK;AAAA,MAC1C;AAEA,aAAO,cAAc,SAAS,IAAI,gBAAgB;AAAA,IACnD;AAAA,IACA,CAAE,UAAW;AAAA,MACZ,uBAAwB,KAAM;AAAA,MAC9B,OAAQ,oBAAAA,KAAiB,EAAE,4BAA4B;AAAA,IACxD;AAAA,EACD;AACD;AAUO,IAAM,0BAAsB;AAAA,EAAwB,CAAE,eAC5D;AAAA,IACC,CAAE,UAAW;AACZ,YAAM,sBAAsB,uBAAwB,KAAM;AAC1D,UAAK,CAAE,oBAAoB,QAAS;AACnC,eAAO;AAAA,MACR;AAEA,YAAM,EAAE,cAAc,4BAA4B,IACjD,OAAQ,oBAAAA,KAAiB;AAC1B,YAAM,sBAAsB,oBAAoB;AAAA,QAC/C,CAAE,cAAe,UAAU;AAAA,MAC5B;AACA,YAAM,kBAAkB,4BAA4B,EAAE;AAAA,QACrD,CAAE,aAAc;AACf,gBAAM,YAAY,aAAc,QAAS;AACzC,iBAAO,oBAAoB,SAAU,SAAU,IAC5C,YACA,CAAC;AAAA,QACL;AAAA,MACD;AACA,YAAM,mBAAmB,oBAAoB;AAAA,QAC5C,CAAE,cAAe,CAAE,gBAAgB,SAAU,UAAU,IAAK;AAAA,MAC7D;AAEA,aAAO,iBAAiB,SAAS,IAAI,mBAAmB;AAAA,IACzD;AAAA,IACA,CAAE,UAAW;AAAA,MACZ,uBAAwB,KAAM;AAAA,MAC9B,OAAQ,oBAAAA,KAAiB,EAAE,4BAA4B;AAAA,IACxD;AAAA,EACD;AACD;AAUO,SAAS,aAAc,OAAO,SAAU;AAC9C,SAAO,MAAM,gBAAgB,aAAc,OAAQ,KAAK;AACzD;AASO,SAAS,gBAAiB,OAAQ;AACxC,SAAO,MAAM;AACd;AAUO,SAAS,uBAAwB,OAAO,SAAU;AACxD,SAAO,MAAM,aAAc,OAAQ;AACpC;",
6
- "names": ["blockEditorStore"]
7
- }
1
+ {"version":3,"file":"selectors.cjs","names":["createRegistrySelector","createSelector","blockEditorStore"],"sources":["../../src/store/selectors.js"],"sourcesContent":["import { createSelector, createRegistrySelector } from '@wordpress/data';\nimport { store as blockEditorStore } from '@wordpress/block-editor';\n\nconst EMPTY_ARRAY = [];\n\n/**\n * Returns true if application is requesting for downloadable blocks.\n *\n * @param {Object} state Global application state.\n * @param {string} filterValue Search string.\n *\n * @return {boolean} Whether a request is in progress for the blocks list.\n */\nexport function isRequestingDownloadableBlocks( state, filterValue ) {\n\treturn state.downloadableBlocks[ filterValue ]?.isRequesting ?? false;\n}\n\n/**\n * Returns the available uninstalled blocks.\n *\n * @param {Object} state Global application state.\n * @param {string} filterValue Search string.\n *\n * @return {Array} Downloadable blocks.\n */\nexport function getDownloadableBlocks( state, filterValue ) {\n\treturn state.downloadableBlocks[ filterValue ]?.results ?? EMPTY_ARRAY;\n}\n\n/**\n * Returns the block types that have been installed on the server in this\n * session.\n *\n * @param {Object} state Global application state.\n *\n * @return {Array} Block type items\n */\nexport function getInstalledBlockTypes( state ) {\n\treturn state.blockManagement.installedBlockTypes;\n}\n\n/**\n * Returns block types that have been installed on the server and used in the\n * current post.\n *\n * @param {Object} state Global application state.\n *\n * @return {Array} Block type items.\n */\nexport const getNewBlockTypes = createRegistrySelector( ( select ) =>\n\tcreateSelector(\n\t\t( state ) => {\n\t\t\tconst installedBlockTypes = getInstalledBlockTypes( state );\n\t\t\tif ( ! installedBlockTypes.length ) {\n\t\t\t\treturn EMPTY_ARRAY;\n\t\t\t}\n\n\t\t\tconst { getBlockName, getClientIdsWithDescendants } =\n\t\t\t\tselect( blockEditorStore );\n\t\t\tconst installedBlockNames = installedBlockTypes.map(\n\t\t\t\t( blockType ) => blockType.name\n\t\t\t);\n\t\t\tconst foundBlockNames = getClientIdsWithDescendants().flatMap(\n\t\t\t\t( clientId ) => {\n\t\t\t\t\tconst blockName = getBlockName( clientId );\n\t\t\t\t\treturn installedBlockNames.includes( blockName )\n\t\t\t\t\t\t? blockName\n\t\t\t\t\t\t: [];\n\t\t\t\t}\n\t\t\t);\n\t\t\tconst newBlockTypes = installedBlockTypes.filter( ( blockType ) =>\n\t\t\t\tfoundBlockNames.includes( blockType.name )\n\t\t\t);\n\n\t\t\treturn newBlockTypes.length > 0 ? newBlockTypes : EMPTY_ARRAY;\n\t\t},\n\t\t( state ) => [\n\t\t\tgetInstalledBlockTypes( state ),\n\t\t\tselect( blockEditorStore ).getClientIdsWithDescendants(),\n\t\t]\n\t)\n);\n\n/**\n * Returns the block types that have been installed on the server but are not\n * used in the current post.\n *\n * @param {Object} state Global application state.\n *\n * @return {Array} Block type items.\n */\nexport const getUnusedBlockTypes = createRegistrySelector( ( select ) =>\n\tcreateSelector(\n\t\t( state ) => {\n\t\t\tconst installedBlockTypes = getInstalledBlockTypes( state );\n\t\t\tif ( ! installedBlockTypes.length ) {\n\t\t\t\treturn EMPTY_ARRAY;\n\t\t\t}\n\n\t\t\tconst { getBlockName, getClientIdsWithDescendants } =\n\t\t\t\tselect( blockEditorStore );\n\t\t\tconst installedBlockNames = installedBlockTypes.map(\n\t\t\t\t( blockType ) => blockType.name\n\t\t\t);\n\t\t\tconst foundBlockNames = getClientIdsWithDescendants().flatMap(\n\t\t\t\t( clientId ) => {\n\t\t\t\t\tconst blockName = getBlockName( clientId );\n\t\t\t\t\treturn installedBlockNames.includes( blockName )\n\t\t\t\t\t\t? blockName\n\t\t\t\t\t\t: [];\n\t\t\t\t}\n\t\t\t);\n\t\t\tconst unusedBlockTypes = installedBlockTypes.filter(\n\t\t\t\t( blockType ) => ! foundBlockNames.includes( blockType.name )\n\t\t\t);\n\n\t\t\treturn unusedBlockTypes.length > 0 ? unusedBlockTypes : EMPTY_ARRAY;\n\t\t},\n\t\t( state ) => [\n\t\t\tgetInstalledBlockTypes( state ),\n\t\t\tselect( blockEditorStore ).getClientIdsWithDescendants(),\n\t\t]\n\t)\n);\n\n/**\n * Returns true if a block plugin install is in progress.\n *\n * @param {Object} state Global application state.\n * @param {string} blockId Id of the block.\n *\n * @return {boolean} Whether this block is currently being installed.\n */\nexport function isInstalling( state, blockId ) {\n\treturn state.blockManagement.isInstalling[ blockId ] || false;\n}\n\n/**\n * Returns all block error notices.\n *\n * @param {Object} state Global application state.\n *\n * @return {Object} Object with error notices.\n */\nexport function getErrorNotices( state ) {\n\treturn state.errorNotices;\n}\n\n/**\n * Returns the error notice for a given block.\n *\n * @param {Object} state Global application state.\n * @param {string} blockId The ID of the block plugin. eg: my-block\n *\n * @return {string|boolean} The error text, or false if no error.\n */\nexport function getErrorNoticeForBlock( state, blockId ) {\n\treturn state.errorNotices[ blockId ];\n}\n"],"mappings":";;;;;;;;AAGA,MAAM,cAAc,CAAC;;;;;;;;;AAUrB,SAAgB,+BAAgC,OAAO,aAAc;CACpE,OAAO,MAAM,mBAAoB,YAAa,EAAE,gBAAgB;AACjE;;;;;;;;;AAUA,SAAgB,sBAAuB,OAAO,aAAc;CAC3D,OAAO,MAAM,mBAAoB,YAAa,EAAE,WAAW;AAC5D;;;;;;;;;AAUA,SAAgB,uBAAwB,OAAQ;CAC/C,OAAO,MAAM,gBAAgB;AAC9B;;;;;;;;;AAUA,MAAa,oBAAA,GAAmBA,gBAAAA,uBAAAA,EAA0B,YAAA,GACzDC,gBAAAA,eAAAA,EACG,UAAW;CACZ,MAAM,sBAAsB,uBAAwB,KAAM;CAC1D,IAAK,CAAE,oBAAoB,QAC1B,OAAO;CAGR,MAAM,EAAE,cAAc,gCACrB,OAAQC,wBAAAA,KAAiB;CAC1B,MAAM,sBAAsB,oBAAoB,KAC7C,cAAe,UAAU,IAC5B;CACA,MAAM,kBAAkB,4BAA4B,CAAC,CAAC,SACnD,aAAc;EACf,MAAM,YAAY,aAAc,QAAS;EACzC,OAAO,oBAAoB,SAAU,SAAU,IAC5C,YACA,CAAC;CACL,CACD;CACA,MAAM,gBAAgB,oBAAoB,QAAU,cACnD,gBAAgB,SAAU,UAAU,IAAK,CAC1C;CAEA,OAAO,cAAc,SAAS,IAAI,gBAAgB;AACnD,IACE,UAAW,CACZ,uBAAwB,KAAM,GAC9B,OAAQA,wBAAAA,KAAiB,CAAC,CAAC,4BAA4B,CACxD,CACD,CACD;;;;;;;;;AAUA,MAAa,uBAAA,GAAsBF,gBAAAA,uBAAAA,EAA0B,YAAA,GAC5DC,gBAAAA,eAAAA,EACG,UAAW;CACZ,MAAM,sBAAsB,uBAAwB,KAAM;CAC1D,IAAK,CAAE,oBAAoB,QAC1B,OAAO;CAGR,MAAM,EAAE,cAAc,gCACrB,OAAQC,wBAAAA,KAAiB;CAC1B,MAAM,sBAAsB,oBAAoB,KAC7C,cAAe,UAAU,IAC5B;CACA,MAAM,kBAAkB,4BAA4B,CAAC,CAAC,SACnD,aAAc;EACf,MAAM,YAAY,aAAc,QAAS;EACzC,OAAO,oBAAoB,SAAU,SAAU,IAC5C,YACA,CAAC;CACL,CACD;CACA,MAAM,mBAAmB,oBAAoB,QAC1C,cAAe,CAAE,gBAAgB,SAAU,UAAU,IAAK,CAC7D;CAEA,OAAO,iBAAiB,SAAS,IAAI,mBAAmB;AACzD,IACE,UAAW,CACZ,uBAAwB,KAAM,GAC9B,OAAQA,wBAAAA,KAAiB,CAAC,CAAC,4BAA4B,CACxD,CACD,CACD;;;;;;;;;AAUA,SAAgB,aAAc,OAAO,SAAU;CAC9C,OAAO,MAAM,gBAAgB,aAAc,YAAa;AACzD;;;;;;;;AASA,SAAgB,gBAAiB,OAAQ;CACxC,OAAO,MAAM;AACd;;;;;;;;;AAUA,SAAgB,uBAAwB,OAAO,SAAU;CACxD,OAAO,MAAM,aAAc;AAC5B"}
@@ -1,35 +1,22 @@
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/utils/get-plugin-url.js
20
- var get_plugin_url_exports = {};
21
- __export(get_plugin_url_exports, {
22
- default: () => getPluginUrl
1
+ "use strict";
2
+ Object.defineProperties(exports, {
3
+ __esModule: { value: true },
4
+ [Symbol.toStringTag]: { value: "Module" }
23
5
  });
24
- module.exports = __toCommonJS(get_plugin_url_exports);
6
+ // packages/block-directory/src/store/utils/get-plugin-url.js
7
+ /**
8
+ * Get the plugin's direct API link out of a block-directory response.
9
+ *
10
+ * @param {Object} block The block object
11
+ *
12
+ * @return {string} The plugin URL, if exists.
13
+ */
25
14
  function getPluginUrl(block) {
26
- if (!block) {
27
- return false;
28
- }
29
- const link = block.links["wp:plugin"] || block.links.self;
30
- if (link && link.length) {
31
- return link[0].href;
32
- }
33
- return false;
15
+ if (!block) return false;
16
+ const link = block.links["wp:plugin"] || block.links.self;
17
+ if (link && link.length) return link[0].href;
18
+ return false;
34
19
  }
35
- //# sourceMappingURL=get-plugin-url.cjs.map
20
+ exports.default = getPluginUrl;
21
+
22
+ //# sourceMappingURL=get-plugin-url.cjs.map
@@ -1,7 +1 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../src/store/utils/get-plugin-url.js"],
4
- "sourcesContent": ["/**\n * Get the plugin's direct API link out of a block-directory response.\n *\n * @param {Object} block The block object\n *\n * @return {string} The plugin URL, if exists.\n */\nexport default function getPluginUrl( block ) {\n\tif ( ! block ) {\n\t\treturn false;\n\t}\n\tconst link = block.links[ 'wp:plugin' ] || block.links.self;\n\tif ( link && link.length ) {\n\t\treturn link[ 0 ].href;\n\t}\n\treturn false;\n}\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAOe,SAAR,aAA+B,OAAQ;AAC7C,MAAK,CAAE,OAAQ;AACd,WAAO;AAAA,EACR;AACA,QAAM,OAAO,MAAM,MAAO,WAAY,KAAK,MAAM,MAAM;AACvD,MAAK,QAAQ,KAAK,QAAS;AAC1B,WAAO,KAAM,CAAE,EAAE;AAAA,EAClB;AACA,SAAO;AACR;",
6
- "names": []
7
- }
1
+ {"version":3,"file":"get-plugin-url.cjs","names":[],"sources":["../../../src/store/utils/get-plugin-url.js"],"sourcesContent":["/**\n * Get the plugin's direct API link out of a block-directory response.\n *\n * @param {Object} block The block object\n *\n * @return {string} The plugin URL, if exists.\n */\nexport default function getPluginUrl( block ) {\n\tif ( ! block ) {\n\t\treturn false;\n\t}\n\tconst link = block.links[ 'wp:plugin' ] || block.links.self;\n\tif ( link && link.length ) {\n\t\treturn link[ 0 ].href;\n\t}\n\treturn false;\n}\n"],"mappings":";;;;;;;;;;;;;AAOA,SAAwB,aAAc,OAAQ;CAC7C,IAAK,CAAE,OACN,OAAO;CAER,MAAM,OAAO,MAAM,MAAO,gBAAiB,MAAM,MAAM;CACvD,IAAK,QAAQ,KAAK,QACjB,OAAO,KAAM,EAAG,CAAC;CAElB,OAAO;AACR"}
@@ -1,30 +1,24 @@
1
- // packages/block-directory/src/components/auto-block-uninstaller/index.js
2
1
  import { unregisterBlockType } from "@wordpress/blocks";
3
2
  import { useDispatch, useSelect } from "@wordpress/data";
4
3
  import { useEffect } from "@wordpress/element";
5
- import { store as editorStore } from "@wordpress/editor";
6
- import { store as blockDirectoryStore } from "../../store/index.mjs";
4
+ import { store } from "@wordpress/editor";
5
+ import { store as store$1 } from "../../store/index.mjs";
6
+ // packages/block-directory/src/components/auto-block-uninstaller/index.js
7
7
  function AutoBlockUninstaller() {
8
- const { uninstallBlockType } = useDispatch(blockDirectoryStore);
9
- const shouldRemoveBlockTypes = useSelect((select) => {
10
- const { isAutosavingPost, isSavingPost } = select(editorStore);
11
- return isSavingPost() && !isAutosavingPost();
12
- }, []);
13
- const unusedBlockTypes = useSelect(
14
- (select) => select(blockDirectoryStore).getUnusedBlockTypes(),
15
- []
16
- );
17
- useEffect(() => {
18
- if (shouldRemoveBlockTypes && unusedBlockTypes.length) {
19
- unusedBlockTypes.forEach((blockType) => {
20
- uninstallBlockType(blockType);
21
- unregisterBlockType(blockType.name);
22
- });
23
- }
24
- }, [shouldRemoveBlockTypes]);
25
- return null;
8
+ const { uninstallBlockType } = useDispatch(store$1);
9
+ const shouldRemoveBlockTypes = useSelect((select) => {
10
+ const { isAutosavingPost, isSavingPost } = select(store);
11
+ return isSavingPost() && !isAutosavingPost();
12
+ }, []);
13
+ const unusedBlockTypes = useSelect((select) => select(store$1).getUnusedBlockTypes(), []);
14
+ useEffect(() => {
15
+ if (shouldRemoveBlockTypes && unusedBlockTypes.length) unusedBlockTypes.forEach((blockType) => {
16
+ uninstallBlockType(blockType);
17
+ unregisterBlockType(blockType.name);
18
+ });
19
+ }, [shouldRemoveBlockTypes]);
20
+ return null;
26
21
  }
27
- export {
28
- AutoBlockUninstaller as default
29
- };
30
- //# sourceMappingURL=index.mjs.map
22
+ export { AutoBlockUninstaller as default };
23
+
24
+ //# sourceMappingURL=index.mjs.map
@@ -1,7 +1 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../src/components/auto-block-uninstaller/index.js"],
4
- "sourcesContent": ["import { unregisterBlockType } from '@wordpress/blocks';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { useEffect } from '@wordpress/element';\nimport { store as editorStore } from '@wordpress/editor';\nimport { store as blockDirectoryStore } from '../../store';\n\nexport default function AutoBlockUninstaller() {\n\tconst { uninstallBlockType } = useDispatch( blockDirectoryStore );\n\n\tconst shouldRemoveBlockTypes = useSelect( ( select ) => {\n\t\tconst { isAutosavingPost, isSavingPost } = select( editorStore );\n\t\treturn isSavingPost() && ! isAutosavingPost();\n\t}, [] );\n\n\tconst unusedBlockTypes = useSelect(\n\t\t( select ) => select( blockDirectoryStore ).getUnusedBlockTypes(),\n\t\t[]\n\t);\n\n\tuseEffect( () => {\n\t\tif ( shouldRemoveBlockTypes && unusedBlockTypes.length ) {\n\t\t\tunusedBlockTypes.forEach( ( blockType ) => {\n\t\t\t\tuninstallBlockType( blockType );\n\t\t\t\tunregisterBlockType( blockType.name );\n\t\t\t} );\n\t\t}\n\t}, [ shouldRemoveBlockTypes ] );\n\n\treturn null;\n}\n"],
5
- "mappings": ";AAAA,SAAS,2BAA2B;AACpC,SAAS,aAAa,iBAAiB;AACvC,SAAS,iBAAiB;AAC1B,SAAS,SAAS,mBAAmB;AACrC,SAAS,SAAS,2BAA2B;AAE9B,SAAR,uBAAwC;AAC9C,QAAM,EAAE,mBAAmB,IAAI,YAAa,mBAAoB;AAEhE,QAAM,yBAAyB,UAAW,CAAE,WAAY;AACvD,UAAM,EAAE,kBAAkB,aAAa,IAAI,OAAQ,WAAY;AAC/D,WAAO,aAAa,KAAK,CAAE,iBAAiB;AAAA,EAC7C,GAAG,CAAC,CAAE;AAEN,QAAM,mBAAmB;AAAA,IACxB,CAAE,WAAY,OAAQ,mBAAoB,EAAE,oBAAoB;AAAA,IAChE,CAAC;AAAA,EACF;AAEA,YAAW,MAAM;AAChB,QAAK,0BAA0B,iBAAiB,QAAS;AACxD,uBAAiB,QAAS,CAAE,cAAe;AAC1C,2BAAoB,SAAU;AAC9B,4BAAqB,UAAU,IAAK;AAAA,MACrC,CAAE;AAAA,IACH;AAAA,EACD,GAAG,CAAE,sBAAuB,CAAE;AAE9B,SAAO;AACR;",
6
- "names": []
7
- }
1
+ {"version":3,"file":"index.mjs","names":["blockDirectoryStore","editorStore"],"sources":["../../../src/components/auto-block-uninstaller/index.js"],"sourcesContent":["import { unregisterBlockType } from '@wordpress/blocks';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { useEffect } from '@wordpress/element';\nimport { store as editorStore } from '@wordpress/editor';\nimport { store as blockDirectoryStore } from '../../store';\n\nexport default function AutoBlockUninstaller() {\n\tconst { uninstallBlockType } = useDispatch( blockDirectoryStore );\n\n\tconst shouldRemoveBlockTypes = useSelect( ( select ) => {\n\t\tconst { isAutosavingPost, isSavingPost } = select( editorStore );\n\t\treturn isSavingPost() && ! isAutosavingPost();\n\t}, [] );\n\n\tconst unusedBlockTypes = useSelect(\n\t\t( select ) => select( blockDirectoryStore ).getUnusedBlockTypes(),\n\t\t[]\n\t);\n\n\tuseEffect( () => {\n\t\tif ( shouldRemoveBlockTypes && unusedBlockTypes.length ) {\n\t\t\tunusedBlockTypes.forEach( ( blockType ) => {\n\t\t\t\tuninstallBlockType( blockType );\n\t\t\t\tunregisterBlockType( blockType.name );\n\t\t\t} );\n\t\t}\n\t}, [ shouldRemoveBlockTypes ] );\n\n\treturn null;\n}\n"],"mappings":";;;;;;AAMA,SAAwB,uBAAuB;CAC9C,MAAM,EAAE,uBAAuB,YAAaA,OAAoB;CAEhE,MAAM,yBAAyB,WAAa,WAAY;EACvD,MAAM,EAAE,kBAAkB,iBAAiB,OAAQC,KAAY;EAC/D,OAAO,aAAa,KAAK,CAAE,iBAAiB;CAC7C,GAAG,CAAC,CAAE;CAEN,MAAM,mBAAmB,WACtB,WAAY,OAAQD,OAAoB,CAAC,CAAC,oBAAoB,GAChE,CAAC,CACF;CAEA,gBAAiB;EAChB,IAAK,0BAA0B,iBAAiB,QAC/C,iBAAiB,SAAW,cAAe;GAC1C,mBAAoB,SAAU;GAC9B,oBAAqB,UAAU,IAAK;EACrC,CAAE;CAEJ,GAAG,CAAE,sBAAuB,CAAE;CAE9B,OAAO;AACR"}
@@ -1,10 +1,10 @@
1
- // packages/block-directory/src/components/block-ratings/index.jsx
2
1
  import Stars from "./stars.mjs";
3
2
  import { jsx } from "react/jsx-runtime";
4
- var BlockRatings = ({ rating }) => /* @__PURE__ */ jsx("span", { className: "block-directory-block-ratings", children: /* @__PURE__ */ jsx(Stars, { rating }) });
5
- var block_ratings_default = BlockRatings;
6
- export {
7
- BlockRatings,
8
- block_ratings_default as default
9
- };
10
- //# sourceMappingURL=index.mjs.map
3
+ // packages/block-directory/src/components/block-ratings/index.jsx
4
+ const BlockRatings = ({ rating }) => /* @__PURE__ */ jsx("span", {
5
+ className: "block-directory-block-ratings",
6
+ children: /* @__PURE__ */ jsx(Stars, { rating })
7
+ });
8
+ export { BlockRatings, BlockRatings as default };
9
+
10
+ //# sourceMappingURL=index.mjs.map
@@ -1,7 +1 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../src/components/block-ratings/index.jsx"],
4
- "sourcesContent": ["import Stars from './stars';\n\nexport const BlockRatings = ( { rating } ) => (\n\t<span className=\"block-directory-block-ratings\">\n\t\t<Stars rating={ rating } />\n\t</span>\n);\n\nexport default BlockRatings;\n"],
5
- "mappings": ";AAAA,OAAO,WAAW;AAIhB;AAFK,IAAM,eAAe,CAAE,EAAE,OAAO,MACtC,oBAAC,UAAK,WAAU,iCACf,8BAAC,SAAM,QAAkB,GAC1B;AAGD,IAAO,wBAAQ;",
6
- "names": []
7
- }
1
+ {"version":3,"file":"index.mjs","names":[],"sources":["../../../src/components/block-ratings/index.jsx"],"sourcesContent":["import Stars from './stars';\n\nexport const BlockRatings = ( { rating } ) => (\n\t<span className=\"block-directory-block-ratings\">\n\t\t<Stars rating={ rating } />\n\t</span>\n);\n\nexport default BlockRatings;\n"],"mappings":";;;AAEA,MAAa,gBAAiB,EAAE,aAC/B,oBAAC,QAAD;CAAM,WAAU;CACf,UAAA,oBAAC,OAAD,EAAgB,OAAU,CAAA;AACrB,CAAA"}
@@ -1,54 +1,33 @@
1
- // packages/block-directory/src/components/block-ratings/stars.jsx
2
1
  import { __, sprintf } from "@wordpress/i18n";
3
2
  import { Icon, starEmpty, starFilled, starHalf } from "@wordpress/icons";
4
3
  import { jsx, jsxs } from "react/jsx-runtime";
4
+ // packages/block-directory/src/components/block-ratings/stars.jsx
5
5
  function Stars({ rating }) {
6
- const stars = Math.round(rating / 0.5) * 0.5;
7
- const fullStarCount = Math.floor(rating);
8
- const halfStarCount = Math.ceil(rating - fullStarCount);
9
- const emptyStarCount = 5 - (fullStarCount + halfStarCount);
10
- return /* @__PURE__ */ jsxs(
11
- "span",
12
- {
13
- "aria-label": sprintf(
14
- /* translators: %s: number of stars. */
15
- __("%s out of 5 stars"),
16
- stars
17
- ),
18
- children: [
19
- Array.from({ length: fullStarCount }).map((_, i) => /* @__PURE__ */ jsx(
20
- Icon,
21
- {
22
- className: "block-directory-block-ratings__star-full",
23
- icon: starFilled,
24
- size: 16
25
- },
26
- `full_stars_${i}`
27
- )),
28
- Array.from({ length: halfStarCount }).map((_, i) => /* @__PURE__ */ jsx(
29
- Icon,
30
- {
31
- className: "block-directory-block-ratings__star-half-full",
32
- icon: starHalf,
33
- size: 16
34
- },
35
- `half_stars_${i}`
36
- )),
37
- Array.from({ length: emptyStarCount }).map((_, i) => /* @__PURE__ */ jsx(
38
- Icon,
39
- {
40
- className: "block-directory-block-ratings__star-empty",
41
- icon: starEmpty,
42
- size: 16
43
- },
44
- `empty_stars_${i}`
45
- ))
46
- ]
47
- }
48
- );
6
+ const stars = Math.round(rating / .5) * .5;
7
+ const fullStarCount = Math.floor(rating);
8
+ const halfStarCount = Math.ceil(rating - fullStarCount);
9
+ const emptyStarCount = 5 - (fullStarCount + halfStarCount);
10
+ return /* @__PURE__ */ jsxs("span", {
11
+ "aria-label": sprintf(__("%s out of 5 stars"), stars),
12
+ children: [
13
+ Array.from({ length: fullStarCount }).map((_, i) => /* @__PURE__ */ jsx(Icon, {
14
+ className: "block-directory-block-ratings__star-full",
15
+ icon: starFilled,
16
+ size: 16
17
+ }, `full_stars_${i}`)),
18
+ Array.from({ length: halfStarCount }).map((_, i) => /* @__PURE__ */ jsx(Icon, {
19
+ className: "block-directory-block-ratings__star-half-full",
20
+ icon: starHalf,
21
+ size: 16
22
+ }, `half_stars_${i}`)),
23
+ Array.from({ length: emptyStarCount }).map((_, i) => /* @__PURE__ */ jsx(Icon, {
24
+ className: "block-directory-block-ratings__star-empty",
25
+ icon: starEmpty,
26
+ size: 16
27
+ }, `empty_stars_${i}`))
28
+ ]
29
+ });
49
30
  }
50
- var stars_default = Stars;
51
- export {
52
- stars_default as default
53
- };
54
- //# sourceMappingURL=stars.mjs.map
31
+ export { Stars as default };
32
+
33
+ //# sourceMappingURL=stars.mjs.map