@wordpress/block-directory 6.0.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.
- package/build/components/auto-block-uninstaller/index.cjs +26 -47
- package/build/components/auto-block-uninstaller/index.cjs.map +1 -7
- package/build/components/block-ratings/index.cjs +28 -34
- package/build/components/block-ratings/index.cjs.map +1 -7
- package/build/components/block-ratings/stars.cjs +35 -71
- package/build/components/block-ratings/stars.cjs.map +1 -7
- package/build/components/compact-list/index.cjs +45 -43
- package/build/components/compact-list/index.cjs.map +1 -7
- package/build/components/downloadable-block-icon/index.cjs +20 -29
- package/build/components/downloadable-block-icon/index.cjs.map +1 -7
- package/build/components/downloadable-block-list-item/index.cjs +95 -161
- package/build/components/downloadable-block-list-item/index.cjs.map +1 -7
- package/build/components/downloadable-block-notice/index.cjs +23 -46
- package/build/components/downloadable-block-notice/index.cjs.map +1 -7
- package/build/components/downloadable-blocks-list/index.cjs +50 -70
- package/build/components/downloadable-blocks-list/index.cjs.map +1 -7
- package/build/components/downloadable-blocks-panel/index.cjs +79 -119
- package/build/components/downloadable-blocks-panel/index.cjs.map +1 -7
- package/build/components/downloadable-blocks-panel/inserter-panel.cjs +37 -61
- package/build/components/downloadable-blocks-panel/inserter-panel.cjs.map +1 -7
- package/build/components/downloadable-blocks-panel/no-results.cjs +27 -46
- package/build/components/downloadable-blocks-panel/no-results.cjs.map +1 -7
- package/build/index.cjs +11 -29
- package/build/plugins/get-install-missing/index.cjs +80 -122
- package/build/plugins/get-install-missing/index.cjs.map +1 -7
- package/build/plugins/get-install-missing/install-button.cjs +33 -70
- package/build/plugins/get-install-missing/install-button.cjs.map +1 -7
- package/build/plugins/index.cjs +45 -45
- package/build/plugins/index.cjs.map +1 -7
- package/build/plugins/inserter-menu-downloadable-blocks-panel/index.cjs +40 -52
- package/build/plugins/inserter-menu-downloadable-blocks-panel/index.cjs.map +1 -7
- package/build/plugins/installed-blocks-pre-publish-panel/index.cjs +38 -62
- package/build/plugins/installed-blocks-pre-publish-panel/index.cjs.map +1 -7
- package/build/store/actions.cjs +233 -205
- package/build/store/actions.cjs.map +1 -7
- package/build/store/index.cjs +56 -45
- package/build/store/index.cjs.map +1 -7
- package/build/store/load-assets.cjs +62 -63
- package/build/store/load-assets.cjs.map +1 -7
- package/build/store/reducer.cjs +90 -101
- package/build/store/reducer.cjs.map +1 -7
- package/build/store/resolvers.cjs +34 -54
- package/build/store/resolvers.cjs.map +1 -7
- package/build/store/selectors.cjs +111 -107
- package/build/store/selectors.cjs.map +1 -7
- package/build/store/utils/get-plugin-url.cjs +19 -32
- package/build/store/utils/get-plugin-url.cjs.map +1 -7
- package/build-module/components/auto-block-uninstaller/index.mjs +19 -25
- package/build-module/components/auto-block-uninstaller/index.mjs.map +1 -7
- package/build-module/components/block-ratings/index.mjs +8 -8
- package/build-module/components/block-ratings/index.mjs.map +1 -7
- package/build-module/components/block-ratings/stars.mjs +28 -49
- package/build-module/components/block-ratings/stars.mjs.map +1 -7
- package/build-module/components/compact-list/index.mjs +24 -19
- package/build-module/components/compact-list/index.mjs.map +1 -7
- package/build-module/components/downloadable-block-icon/index.mjs +14 -8
- package/build-module/components/downloadable-block-icon/index.mjs.map +1 -7
- package/build-module/components/downloadable-block-list-item/index.mjs +64 -130
- package/build-module/components/downloadable-block-list-item/index.mjs.map +1 -7
- package/build-module/components/downloadable-block-notice/index.mjs +15 -20
- package/build-module/components/downloadable-block-notice/index.mjs.map +1 -7
- package/build-module/components/downloadable-blocks-list/index.mjs +26 -43
- package/build-module/components/downloadable-blocks-list/index.mjs.map +1 -7
- package/build-module/components/downloadable-blocks-panel/index.mjs +52 -91
- package/build-module/components/downloadable-blocks-panel/index.mjs.map +1 -7
- package/build-module/components/downloadable-blocks-panel/inserter-panel.mjs +29 -38
- package/build-module/components/downloadable-blocks-panel/inserter-panel.mjs.map +1 -7
- package/build-module/components/downloadable-blocks-panel/no-results.mjs +19 -23
- package/build-module/components/downloadable-blocks-panel/no-results.mjs.map +1 -7
- package/build-module/index.mjs +1 -6
- package/build-module/plugins/get-install-missing/index.mjs +55 -98
- package/build-module/plugins/get-install-missing/index.mjs.map +1 -7
- package/build-module/plugins/get-install-missing/install-button.mjs +25 -47
- package/build-module/plugins/get-install-missing/install-button.mjs.map +1 -7
- package/build-module/plugins/index.mjs +16 -23
- package/build-module/plugins/index.mjs.map +1 -7
- package/build-module/plugins/inserter-menu-downloadable-blocks-panel/index.mjs +17 -26
- package/build-module/plugins/inserter-menu-downloadable-blocks-panel/index.mjs.map +1 -7
- package/build-module/plugins/installed-blocks-pre-publish-panel/index.mjs +15 -36
- package/build-module/plugins/installed-blocks-pre-publish-panel/index.mjs.map +1 -7
- package/build-module/store/actions.mjs +201 -170
- package/build-module/store/actions.mjs.map +1 -7
- package/build-module/store/index.mjs +28 -13
- package/build-module/store/index.mjs.map +1 -7
- package/build-module/store/load-assets.mjs +42 -36
- package/build-module/store/load-assets.mjs.map +1 -7
- package/build-module/store/reducer.mjs +81 -74
- package/build-module/store/reducer.mjs.map +1 -7
- package/build-module/store/resolvers.mjs +13 -26
- package/build-module/store/resolvers.mjs.map +1 -7
- package/build-module/store/selectors.mjs +99 -76
- package/build-module/store/selectors.mjs.map +1 -7
- package/build-module/store/utils/get-plugin-url.mjs +14 -12
- package/build-module/store/utils/get-plugin-url.mjs.map +1 -7
- package/build-style/style-rtl.css +6 -12
- package/build-style/style.css +6 -12
- package/package.json +22 -23
- package/src/components/downloadable-block-list-item/style.scss +6 -6
- package/build/index.cjs.map +0 -7
- package/build/lock-unlock.cjs +0 -36
- package/build/lock-unlock.cjs.map +0 -7
- package/build-module/index.mjs.map +0 -7
- package/build-module/lock-unlock.mjs +0 -11
- package/build-module/lock-unlock.mjs.map +0 -7
- package/src/lock-unlock.js +0 -7
|
@@ -1,73 +1,49 @@
|
|
|
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
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
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
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
)
|
|
27
|
-
|
|
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_i18n = require("@wordpress/i18n");
|
|
28
|
+
let _wordpress_data = require("@wordpress/data");
|
|
29
|
+
let _wordpress_editor = require("@wordpress/editor");
|
|
30
|
+
let ______components_compact_list_index_jsx = require("../../components/compact-list/index.cjs");
|
|
31
|
+
______components_compact_list_index_jsx = __toESM(______components_compact_list_index_jsx);
|
|
32
|
+
let ______store_index_js = require("../../store/index.cjs");
|
|
33
|
+
let react_jsx_runtime = require("react/jsx-runtime");
|
|
29
34
|
// packages/block-directory/src/plugins/installed-blocks-pre-publish-panel/index.jsx
|
|
30
|
-
var installed_blocks_pre_publish_panel_exports = {};
|
|
31
|
-
__export(installed_blocks_pre_publish_panel_exports, {
|
|
32
|
-
default: () => InstalledBlocksPrePublishPanel
|
|
33
|
-
});
|
|
34
|
-
module.exports = __toCommonJS(installed_blocks_pre_publish_panel_exports);
|
|
35
|
-
var import_i18n = require("@wordpress/i18n");
|
|
36
|
-
var import_data = require("@wordpress/data");
|
|
37
|
-
var import_editor = require("@wordpress/editor");
|
|
38
|
-
var import_compact_list = __toESM(require("../../components/compact-list/index.cjs"));
|
|
39
|
-
var import_store = require("../../store/index.cjs");
|
|
40
|
-
var import_jsx_runtime = require("react/jsx-runtime");
|
|
41
35
|
function InstalledBlocksPrePublishPanel() {
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
title: (0, import_i18n.sprintf)(
|
|
53
|
-
// translators: %d: number of blocks (number).
|
|
54
|
-
(0, import_i18n._n)(
|
|
55
|
-
"Added: %d block",
|
|
56
|
-
"Added: %d blocks",
|
|
57
|
-
newBlockTypes.length
|
|
58
|
-
),
|
|
59
|
-
newBlockTypes.length
|
|
60
|
-
),
|
|
61
|
-
initialOpen: true,
|
|
62
|
-
children: [
|
|
63
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { className: "installed-blocks-pre-publish-panel__copy", children: (0, import_i18n._n)(
|
|
64
|
-
"The following block has been added to your site.",
|
|
65
|
-
"The following blocks have been added to your site.",
|
|
66
|
-
newBlockTypes.length
|
|
67
|
-
) }),
|
|
68
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_compact_list.default, { items: newBlockTypes })
|
|
69
|
-
]
|
|
70
|
-
}
|
|
71
|
-
);
|
|
36
|
+
const newBlockTypes = (0, _wordpress_data.useSelect)((select) => select(______store_index_js.store).getNewBlockTypes(), []);
|
|
37
|
+
if (!newBlockTypes.length) return null;
|
|
38
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(_wordpress_editor.PluginPrePublishPanel, {
|
|
39
|
+
title: (0, _wordpress_i18n.sprintf)((0, _wordpress_i18n._n)("Added: %d block", "Added: %d blocks", newBlockTypes.length), newBlockTypes.length),
|
|
40
|
+
initialOpen: true,
|
|
41
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
42
|
+
className: "installed-blocks-pre-publish-panel__copy",
|
|
43
|
+
children: (0, _wordpress_i18n._n)("The following block has been added to your site.", "The following blocks have been added to your site.", newBlockTypes.length)
|
|
44
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(______components_compact_list_index_jsx.default, { items: newBlockTypes })]
|
|
45
|
+
});
|
|
72
46
|
}
|
|
73
|
-
|
|
47
|
+
exports.default = InstalledBlocksPrePublishPanel;
|
|
48
|
+
|
|
49
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -1,7 +1 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../src/plugins/installed-blocks-pre-publish-panel/index.jsx"],
|
|
4
|
-
"sourcesContent": ["import { _n, sprintf } from '@wordpress/i18n';\nimport { useSelect } from '@wordpress/data';\nimport { PluginPrePublishPanel } from '@wordpress/editor';\nimport CompactList from '../../components/compact-list';\nimport { store as blockDirectoryStore } from '../../store';\n\nexport default function InstalledBlocksPrePublishPanel() {\n\tconst newBlockTypes = useSelect(\n\t\t( select ) => select( blockDirectoryStore ).getNewBlockTypes(),\n\t\t[]\n\t);\n\n\tif ( ! newBlockTypes.length ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<PluginPrePublishPanel\n\t\t\ttitle={ sprintf(\n\t\t\t\t// translators: %d: number of blocks (number).\n\t\t\t\t_n(\n\t\t\t\t\t'Added: %d block',\n\t\t\t\t\t'Added: %d blocks',\n\t\t\t\t\tnewBlockTypes.length\n\t\t\t\t),\n\t\t\t\tnewBlockTypes.length\n\t\t\t) }\n\t\t\tinitialOpen\n\t\t>\n\t\t\t<p className=\"installed-blocks-pre-publish-panel__copy\">\n\t\t\t\t{ _n(\n\t\t\t\t\t'The following block has been added to your site.',\n\t\t\t\t\t'The following blocks have been added to your site.',\n\t\t\t\t\tnewBlockTypes.length\n\t\t\t\t) }\n\t\t\t</p>\n\t\t\t<CompactList items={ newBlockTypes } />\n\t\t</PluginPrePublishPanel>\n\t);\n}\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAA4B;AAC5B,kBAA0B;AAC1B,oBAAsC;AACtC,0BAAwB;AACxB,mBAA6C;AAa3C;AAXa,SAAR,iCAAkD;AACxD,QAAM,oBAAgB;AAAA,IACrB,CAAE,WAAY,OAAQ,aAAAA,KAAoB,EAAE,iBAAiB;AAAA,IAC7D,CAAC;AAAA,EACF;AAEA,MAAK,CAAE,cAAc,QAAS;AAC7B,WAAO;AAAA,EACR;AAEA,SACC;AAAA,IAAC;AAAA;AAAA,MACA,WAAQ;AAAA;AAAA,YAEP;AAAA,UACC;AAAA,UACA;AAAA,UACA,cAAc;AAAA,QACf;AAAA,QACA,cAAc;AAAA,MACf;AAAA,MACA,aAAW;AAAA,MAEX;AAAA,oDAAC,OAAE,WAAU,4CACV;AAAA,UACD;AAAA,UACA;AAAA,UACA,cAAc;AAAA,QACf,GACD;AAAA,QACA,4CAAC,oBAAAC,SAAA,EAAY,OAAQ,eAAgB;AAAA;AAAA;AAAA,EACtC;AAEF;",
|
|
6
|
-
"names": ["blockDirectoryStore", "CompactList"]
|
|
7
|
-
}
|
|
1
|
+
{"version":3,"file":"index.cjs","names":["useSelect","blockDirectoryStore","PluginPrePublishPanel","sprintf","_n","CompactList"],"sources":["../../../src/plugins/installed-blocks-pre-publish-panel/index.jsx"],"sourcesContent":["import { _n, sprintf } from '@wordpress/i18n';\nimport { useSelect } from '@wordpress/data';\nimport { PluginPrePublishPanel } from '@wordpress/editor';\nimport CompactList from '../../components/compact-list';\nimport { store as blockDirectoryStore } from '../../store';\n\nexport default function InstalledBlocksPrePublishPanel() {\n\tconst newBlockTypes = useSelect(\n\t\t( select ) => select( blockDirectoryStore ).getNewBlockTypes(),\n\t\t[]\n\t);\n\n\tif ( ! newBlockTypes.length ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<PluginPrePublishPanel\n\t\t\ttitle={ sprintf(\n\t\t\t\t// translators: %d: number of blocks (number).\n\t\t\t\t_n(\n\t\t\t\t\t'Added: %d block',\n\t\t\t\t\t'Added: %d blocks',\n\t\t\t\t\tnewBlockTypes.length\n\t\t\t\t),\n\t\t\t\tnewBlockTypes.length\n\t\t\t) }\n\t\t\tinitialOpen\n\t\t>\n\t\t\t<p className=\"installed-blocks-pre-publish-panel__copy\">\n\t\t\t\t{ _n(\n\t\t\t\t\t'The following block has been added to your site.',\n\t\t\t\t\t'The following blocks have been added to your site.',\n\t\t\t\t\tnewBlockTypes.length\n\t\t\t\t) }\n\t\t\t</p>\n\t\t\t<CompactList items={ newBlockTypes } />\n\t\t</PluginPrePublishPanel>\n\t);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAMA,SAAwB,iCAAiC;CACxD,MAAM,iBAAA,GAAgBA,gBAAAA,UAAAA,EACnB,WAAY,OAAQC,qBAAAA,KAAoB,CAAC,CAAC,iBAAiB,GAC7D,CAAC,CACF;CAEA,IAAK,CAAE,cAAc,QACpB,OAAO;CAGR,OACC,iBAAA,GAAA,kBAAA,KAAA,CAACC,kBAAAA,uBAAD;EACC,QAAA,GAAQC,gBAAAA,QAAAA,EAAAA,GAEPC,gBAAAA,GAAAA,CACC,mBACA,oBACA,cAAc,MACf,GACA,cAAc,MACf;EACA,aAAA;EAVD,UAAA,CAYC,iBAAA,GAAA,kBAAA,IAAA,CAAC,KAAD;GAAG,WAAU;GACVA,WAAAA,GAAAA,gBAAAA,GAAAA,CACD,oDACA,sDACA,cAAc,MACf;EACE,CAAA,GACH,iBAAA,GAAA,kBAAA,IAAA,CAACC,wCAAAA,SAAD,EAAa,OAAQ,cAAiB,CAAA,CAChB;;AAEzB"}
|
package/build/store/actions.cjs
CHANGED
|
@@ -1,230 +1,258 @@
|
|
|
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
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
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
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
)
|
|
27
|
-
|
|
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_blocks = require("@wordpress/blocks");
|
|
28
|
+
let _wordpress_i18n = require("@wordpress/i18n");
|
|
29
|
+
let _wordpress_api_fetch = require("@wordpress/api-fetch");
|
|
30
|
+
_wordpress_api_fetch = __toESM(_wordpress_api_fetch);
|
|
31
|
+
let _wordpress_notices = require("@wordpress/notices");
|
|
32
|
+
let _wordpress_url = require("@wordpress/url");
|
|
33
|
+
let __load_assets_js = require("./load-assets.cjs");
|
|
34
|
+
let __utils_get_plugin_url_js = require("./utils/get-plugin-url.cjs");
|
|
35
|
+
__utils_get_plugin_url_js = __toESM(__utils_get_plugin_url_js);
|
|
29
36
|
// packages/block-directory/src/store/actions.js
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
setErrorNotice: () => setErrorNotice,
|
|
39
|
-
setIsInstalling: () => setIsInstalling,
|
|
40
|
-
uninstallBlockType: () => uninstallBlockType
|
|
41
|
-
});
|
|
42
|
-
module.exports = __toCommonJS(actions_exports);
|
|
43
|
-
var import_blocks = require("@wordpress/blocks");
|
|
44
|
-
var import_i18n = require("@wordpress/i18n");
|
|
45
|
-
var import_api_fetch = __toESM(require("@wordpress/api-fetch"));
|
|
46
|
-
var import_notices = require("@wordpress/notices");
|
|
47
|
-
var import_url = require("@wordpress/url");
|
|
48
|
-
var import_load_assets = require("./load-assets.cjs");
|
|
49
|
-
var import_get_plugin_url = __toESM(require("./utils/get-plugin-url.cjs"));
|
|
37
|
+
/**
|
|
38
|
+
* Returns an action object used in signalling that the downloadable blocks
|
|
39
|
+
* have been requested and are loading.
|
|
40
|
+
*
|
|
41
|
+
* @param {string} filterValue Search string.
|
|
42
|
+
*
|
|
43
|
+
* @return {Object} Action object.
|
|
44
|
+
*/
|
|
50
45
|
function fetchDownloadableBlocks(filterValue) {
|
|
51
|
-
|
|
46
|
+
return {
|
|
47
|
+
type: "FETCH_DOWNLOADABLE_BLOCKS",
|
|
48
|
+
filterValue
|
|
49
|
+
};
|
|
52
50
|
}
|
|
51
|
+
/**
|
|
52
|
+
* Returns an action object used in signalling that the downloadable blocks
|
|
53
|
+
* have been updated.
|
|
54
|
+
*
|
|
55
|
+
* @param {Array} downloadableBlocks Downloadable blocks.
|
|
56
|
+
* @param {string} filterValue Search string.
|
|
57
|
+
*
|
|
58
|
+
* @return {Object} Action object.
|
|
59
|
+
*/
|
|
53
60
|
function receiveDownloadableBlocks(downloadableBlocks, filterValue) {
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
61
|
+
return {
|
|
62
|
+
type: "RECEIVE_DOWNLOADABLE_BLOCKS",
|
|
63
|
+
downloadableBlocks,
|
|
64
|
+
filterValue
|
|
65
|
+
};
|
|
59
66
|
}
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
const fatalAPIErrors = {
|
|
146
|
-
folder_exists: (0, import_i18n.__)(
|
|
147
|
-
"This block is already installed. Try reloading the page."
|
|
148
|
-
),
|
|
149
|
-
unable_to_connect_to_filesystem: (0, import_i18n.__)(
|
|
150
|
-
"Error installing block. You can reload the page and try again."
|
|
151
|
-
)
|
|
152
|
-
};
|
|
153
|
-
if (fatalAPIErrors[error.code]) {
|
|
154
|
-
isFatal = true;
|
|
155
|
-
message = fatalAPIErrors[error.code];
|
|
156
|
-
}
|
|
157
|
-
dispatch.setErrorNotice(id, message, isFatal);
|
|
158
|
-
registry.dispatch(import_notices.store).createErrorNotice(message, {
|
|
159
|
-
speak: true,
|
|
160
|
-
isDismissible: true
|
|
161
|
-
});
|
|
162
|
-
}
|
|
163
|
-
dispatch.setIsInstalling(id, false);
|
|
164
|
-
return success;
|
|
67
|
+
/**
|
|
68
|
+
* Action triggered to install a block plugin.
|
|
69
|
+
*
|
|
70
|
+
* @param {Object} block The block item returned by search.
|
|
71
|
+
*
|
|
72
|
+
* @return {boolean} Whether the block was successfully installed & loaded.
|
|
73
|
+
*/
|
|
74
|
+
const installBlockType = (block) => async ({ registry, dispatch }) => {
|
|
75
|
+
const { id, name } = block;
|
|
76
|
+
let success = false;
|
|
77
|
+
dispatch.clearErrorNotice(id);
|
|
78
|
+
try {
|
|
79
|
+
dispatch.setIsInstalling(id, true);
|
|
80
|
+
const url = (0, __utils_get_plugin_url_js.default)(block);
|
|
81
|
+
let links = {};
|
|
82
|
+
if (url) await (0, _wordpress_api_fetch.default)({
|
|
83
|
+
method: "PUT",
|
|
84
|
+
url,
|
|
85
|
+
data: { status: "active" }
|
|
86
|
+
});
|
|
87
|
+
else links = (await (0, _wordpress_api_fetch.default)({
|
|
88
|
+
method: "POST",
|
|
89
|
+
path: "wp/v2/plugins",
|
|
90
|
+
data: {
|
|
91
|
+
slug: id,
|
|
92
|
+
status: "active"
|
|
93
|
+
}
|
|
94
|
+
}))._links;
|
|
95
|
+
dispatch.addInstalledBlockType({
|
|
96
|
+
...block,
|
|
97
|
+
links: {
|
|
98
|
+
...block.links,
|
|
99
|
+
...links
|
|
100
|
+
}
|
|
101
|
+
});
|
|
102
|
+
const metadataFields = [
|
|
103
|
+
"api_version",
|
|
104
|
+
"title",
|
|
105
|
+
"category",
|
|
106
|
+
"parent",
|
|
107
|
+
"ancestor",
|
|
108
|
+
"icon",
|
|
109
|
+
"description",
|
|
110
|
+
"keywords",
|
|
111
|
+
"attributes",
|
|
112
|
+
"provides_context",
|
|
113
|
+
"uses_context",
|
|
114
|
+
"selectors",
|
|
115
|
+
"supports",
|
|
116
|
+
"styles",
|
|
117
|
+
"example",
|
|
118
|
+
"variations",
|
|
119
|
+
"allowed_blocks",
|
|
120
|
+
"block_hooks"
|
|
121
|
+
];
|
|
122
|
+
await (0, _wordpress_api_fetch.default)({ path: (0, _wordpress_url.addQueryArgs)(`/wp/v2/block-types/${name}`, { _fields: metadataFields }) }).catch(() => {}).then((response) => {
|
|
123
|
+
if (!response) return;
|
|
124
|
+
(0, _wordpress_blocks.unstable__bootstrapServerSideBlockDefinitions)({ [name]: Object.fromEntries(Object.entries(response).filter(([key]) => metadataFields.includes(key))) });
|
|
125
|
+
});
|
|
126
|
+
await (0, __load_assets_js.loadAssets)();
|
|
127
|
+
if (!registry.select(_wordpress_blocks.store).getBlockTypes().some((i) => i.name === name)) throw new Error((0, _wordpress_i18n.__)("Error registering block. Try reloading the page."));
|
|
128
|
+
registry.dispatch(_wordpress_notices.store).createInfoNotice((0, _wordpress_i18n.sprintf)((0, _wordpress_i18n.__)("Block %s installed and added."), block.title), {
|
|
129
|
+
speak: true,
|
|
130
|
+
type: "snackbar"
|
|
131
|
+
});
|
|
132
|
+
success = true;
|
|
133
|
+
} catch (error) {
|
|
134
|
+
let message = error.message || (0, _wordpress_i18n.__)("An error occurred.");
|
|
135
|
+
let isFatal = error instanceof Error;
|
|
136
|
+
const fatalAPIErrors = {
|
|
137
|
+
folder_exists: (0, _wordpress_i18n.__)("This block is already installed. Try reloading the page."),
|
|
138
|
+
unable_to_connect_to_filesystem: (0, _wordpress_i18n.__)("Error installing block. You can reload the page and try again.")
|
|
139
|
+
};
|
|
140
|
+
if (fatalAPIErrors[error.code]) {
|
|
141
|
+
isFatal = true;
|
|
142
|
+
message = fatalAPIErrors[error.code];
|
|
143
|
+
}
|
|
144
|
+
dispatch.setErrorNotice(id, message, isFatal);
|
|
145
|
+
registry.dispatch(_wordpress_notices.store).createErrorNotice(message, {
|
|
146
|
+
speak: true,
|
|
147
|
+
isDismissible: true
|
|
148
|
+
});
|
|
149
|
+
}
|
|
150
|
+
dispatch.setIsInstalling(id, false);
|
|
151
|
+
return success;
|
|
165
152
|
};
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
153
|
+
/**
|
|
154
|
+
* Action triggered to uninstall a block plugin.
|
|
155
|
+
*
|
|
156
|
+
* @param {Object} block The blockType object.
|
|
157
|
+
*/
|
|
158
|
+
const uninstallBlockType = (block) => async ({ registry, dispatch }) => {
|
|
159
|
+
try {
|
|
160
|
+
const url = (0, __utils_get_plugin_url_js.default)(block);
|
|
161
|
+
await (0, _wordpress_api_fetch.default)({
|
|
162
|
+
method: "PUT",
|
|
163
|
+
url,
|
|
164
|
+
data: { status: "inactive" }
|
|
165
|
+
});
|
|
166
|
+
await (0, _wordpress_api_fetch.default)({
|
|
167
|
+
method: "DELETE",
|
|
168
|
+
url
|
|
169
|
+
});
|
|
170
|
+
dispatch.removeInstalledBlockType(block);
|
|
171
|
+
} catch (error) {
|
|
172
|
+
registry.dispatch(_wordpress_notices.store).createErrorNotice(error.message || (0, _wordpress_i18n.__)("An error occurred."));
|
|
173
|
+
}
|
|
184
174
|
};
|
|
175
|
+
/**
|
|
176
|
+
* Returns an action object used to add a block type to the "newly installed"
|
|
177
|
+
* tracking list.
|
|
178
|
+
*
|
|
179
|
+
* @param {Object} item The block item with the block id and name.
|
|
180
|
+
*
|
|
181
|
+
* @return {Object} Action object.
|
|
182
|
+
*/
|
|
185
183
|
function addInstalledBlockType(item) {
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
184
|
+
return {
|
|
185
|
+
type: "ADD_INSTALLED_BLOCK_TYPE",
|
|
186
|
+
item
|
|
187
|
+
};
|
|
190
188
|
}
|
|
189
|
+
/**
|
|
190
|
+
* Returns an action object used to remove a block type from the "newly installed"
|
|
191
|
+
* tracking list.
|
|
192
|
+
*
|
|
193
|
+
* @param {string} item The block item with the block id and name.
|
|
194
|
+
*
|
|
195
|
+
* @return {Object} Action object.
|
|
196
|
+
*/
|
|
191
197
|
function removeInstalledBlockType(item) {
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
198
|
+
return {
|
|
199
|
+
type: "REMOVE_INSTALLED_BLOCK_TYPE",
|
|
200
|
+
item
|
|
201
|
+
};
|
|
196
202
|
}
|
|
203
|
+
/**
|
|
204
|
+
* Returns an action object used to indicate install in progress.
|
|
205
|
+
*
|
|
206
|
+
* @param {string} blockId
|
|
207
|
+
* @param {boolean} isInstalling
|
|
208
|
+
*
|
|
209
|
+
* @return {Object} Action object.
|
|
210
|
+
*/
|
|
197
211
|
function setIsInstalling(blockId, isInstalling) {
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
212
|
+
return {
|
|
213
|
+
type: "SET_INSTALLING_BLOCK",
|
|
214
|
+
blockId,
|
|
215
|
+
isInstalling
|
|
216
|
+
};
|
|
203
217
|
}
|
|
218
|
+
/**
|
|
219
|
+
* Sets an error notice to be displayed to the user for a given block.
|
|
220
|
+
*
|
|
221
|
+
* @param {string} blockId The ID of the block plugin. eg: my-block
|
|
222
|
+
* @param {string} message The message shown in the notice.
|
|
223
|
+
* @param {boolean} isFatal Whether the user can recover from the error.
|
|
224
|
+
*
|
|
225
|
+
* @return {Object} Action object.
|
|
226
|
+
*/
|
|
204
227
|
function setErrorNotice(blockId, message, isFatal = false) {
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
228
|
+
return {
|
|
229
|
+
type: "SET_ERROR_NOTICE",
|
|
230
|
+
blockId,
|
|
231
|
+
message,
|
|
232
|
+
isFatal
|
|
233
|
+
};
|
|
211
234
|
}
|
|
235
|
+
/**
|
|
236
|
+
* Sets the error notice to empty for specific block.
|
|
237
|
+
*
|
|
238
|
+
* @param {string} blockId The ID of the block plugin. eg: my-block
|
|
239
|
+
*
|
|
240
|
+
* @return {Object} Action object.
|
|
241
|
+
*/
|
|
212
242
|
function clearErrorNotice(blockId) {
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
243
|
+
return {
|
|
244
|
+
type: "CLEAR_ERROR_NOTICE",
|
|
245
|
+
blockId
|
|
246
|
+
};
|
|
217
247
|
}
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
});
|
|
230
|
-
//# sourceMappingURL=actions.cjs.map
|
|
248
|
+
exports.addInstalledBlockType = addInstalledBlockType;
|
|
249
|
+
exports.clearErrorNotice = clearErrorNotice;
|
|
250
|
+
exports.fetchDownloadableBlocks = fetchDownloadableBlocks;
|
|
251
|
+
exports.installBlockType = installBlockType;
|
|
252
|
+
exports.receiveDownloadableBlocks = receiveDownloadableBlocks;
|
|
253
|
+
exports.removeInstalledBlockType = removeInstalledBlockType;
|
|
254
|
+
exports.setErrorNotice = setErrorNotice;
|
|
255
|
+
exports.setIsInstalling = setIsInstalling;
|
|
256
|
+
exports.uninstallBlockType = uninstallBlockType;
|
|
257
|
+
|
|
258
|
+
//# sourceMappingURL=actions.cjs.map
|