@wordpress/data-controls 4.32.0 → 4.32.1-next.47f435fc9.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/index.js +72 -136
- package/build/index.js.map +7 -1
- package/build-module/index.js +36 -125
- package/build-module/index.js.map +7 -1
- package/package.json +13 -6
package/build/index.js
CHANGED
|
@@ -1,160 +1,96 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
var
|
|
4
|
-
Object.
|
|
5
|
-
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
var index_exports = {};
|
|
30
|
+
__export(index_exports, {
|
|
31
|
+
__unstableAwaitPromise: () => __unstableAwaitPromise,
|
|
32
|
+
apiFetch: () => apiFetch,
|
|
33
|
+
controls: () => controls,
|
|
34
|
+
dispatch: () => dispatch,
|
|
35
|
+
select: () => select,
|
|
36
|
+
syncSelect: () => syncSelect
|
|
6
37
|
});
|
|
7
|
-
exports
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
exports.select = select;
|
|
12
|
-
exports.syncSelect = syncSelect;
|
|
13
|
-
var _apiFetch = _interopRequireDefault(require("@wordpress/api-fetch"));
|
|
14
|
-
var _data = require("@wordpress/data");
|
|
15
|
-
var _deprecated = _interopRequireDefault(require("@wordpress/deprecated"));
|
|
16
|
-
/**
|
|
17
|
-
* WordPress dependencies
|
|
18
|
-
*/
|
|
19
|
-
|
|
20
|
-
/**
|
|
21
|
-
* Dispatches a control action for triggering an api fetch call.
|
|
22
|
-
*
|
|
23
|
-
* @param {Object} request Arguments for the fetch request.
|
|
24
|
-
*
|
|
25
|
-
* @example
|
|
26
|
-
* ```js
|
|
27
|
-
* import { apiFetch } from '@wordpress/data-controls';
|
|
28
|
-
*
|
|
29
|
-
* // Action generator using apiFetch
|
|
30
|
-
* export function* myAction() {
|
|
31
|
-
* const path = '/v2/my-api/items';
|
|
32
|
-
* const items = yield apiFetch( { path } );
|
|
33
|
-
* // do something with the items.
|
|
34
|
-
* }
|
|
35
|
-
* ```
|
|
36
|
-
*
|
|
37
|
-
* @return {Object} The control descriptor.
|
|
38
|
-
*/
|
|
38
|
+
module.exports = __toCommonJS(index_exports);
|
|
39
|
+
var import_api_fetch = __toESM(require("@wordpress/api-fetch"));
|
|
40
|
+
var import_data = require("@wordpress/data");
|
|
41
|
+
var import_deprecated = __toESM(require("@wordpress/deprecated"));
|
|
39
42
|
function apiFetch(request) {
|
|
40
43
|
return {
|
|
41
|
-
type:
|
|
44
|
+
type: "API_FETCH",
|
|
42
45
|
request
|
|
43
46
|
};
|
|
44
47
|
}
|
|
45
|
-
|
|
46
|
-
/**
|
|
47
|
-
* Control for resolving a selector in a registered data store.
|
|
48
|
-
* Alias for the `resolveSelect` built-in control in the `@wordpress/data` package.
|
|
49
|
-
*
|
|
50
|
-
* @param storeNameOrDescriptor The store object or identifier.
|
|
51
|
-
* @param selectorName The selector name.
|
|
52
|
-
* @param args Arguments passed without change to the `@wordpress/data` control.
|
|
53
|
-
*/
|
|
54
48
|
function select(storeNameOrDescriptor, selectorName, ...args) {
|
|
55
|
-
(0,
|
|
56
|
-
since:
|
|
57
|
-
alternative:
|
|
49
|
+
(0, import_deprecated.default)("`select` control in `@wordpress/data-controls`", {
|
|
50
|
+
since: "5.7",
|
|
51
|
+
alternative: "built-in `resolveSelect` control in `@wordpress/data`"
|
|
58
52
|
});
|
|
59
|
-
return
|
|
53
|
+
return import_data.controls.resolveSelect(
|
|
54
|
+
storeNameOrDescriptor,
|
|
55
|
+
selectorName,
|
|
56
|
+
...args
|
|
57
|
+
);
|
|
60
58
|
}
|
|
61
|
-
|
|
62
|
-
/**
|
|
63
|
-
* Control for calling a selector in a registered data store.
|
|
64
|
-
* Alias for the `select` built-in control in the `@wordpress/data` package.
|
|
65
|
-
*
|
|
66
|
-
* @param storeNameOrDescriptor The store object or identifier.
|
|
67
|
-
* @param selectorName The selector name.
|
|
68
|
-
* @param args Arguments passed without change to the `@wordpress/data` control.
|
|
69
|
-
*/
|
|
70
59
|
function syncSelect(storeNameOrDescriptor, selectorName, ...args) {
|
|
71
|
-
(0,
|
|
72
|
-
since:
|
|
73
|
-
alternative:
|
|
60
|
+
(0, import_deprecated.default)("`syncSelect` control in `@wordpress/data-controls`", {
|
|
61
|
+
since: "5.7",
|
|
62
|
+
alternative: "built-in `select` control in `@wordpress/data`"
|
|
74
63
|
});
|
|
75
|
-
return
|
|
64
|
+
return import_data.controls.select(storeNameOrDescriptor, selectorName, ...args);
|
|
76
65
|
}
|
|
77
|
-
|
|
78
|
-
/**
|
|
79
|
-
* Control for dispatching an action in a registered data store.
|
|
80
|
-
* Alias for the `dispatch` control in the `@wordpress/data` package.
|
|
81
|
-
*
|
|
82
|
-
* @param storeNameOrDescriptor The store object or identifier.
|
|
83
|
-
* @param actionName The action name.
|
|
84
|
-
* @param args Arguments passed without change to the `@wordpress/data` control.
|
|
85
|
-
*/
|
|
86
66
|
function dispatch(storeNameOrDescriptor, actionName, ...args) {
|
|
87
|
-
(0,
|
|
88
|
-
since:
|
|
89
|
-
alternative:
|
|
67
|
+
(0, import_deprecated.default)("`dispatch` control in `@wordpress/data-controls`", {
|
|
68
|
+
since: "5.7",
|
|
69
|
+
alternative: "built-in `dispatch` control in `@wordpress/data`"
|
|
90
70
|
});
|
|
91
|
-
return
|
|
71
|
+
return import_data.controls.dispatch(storeNameOrDescriptor, actionName, ...args);
|
|
92
72
|
}
|
|
93
|
-
|
|
94
|
-
/**
|
|
95
|
-
* Dispatches a control action for awaiting on a promise to be resolved.
|
|
96
|
-
*
|
|
97
|
-
* @param {Object} promise Promise to wait for.
|
|
98
|
-
*
|
|
99
|
-
* @example
|
|
100
|
-
* ```js
|
|
101
|
-
* import { __unstableAwaitPromise } from '@wordpress/data-controls';
|
|
102
|
-
*
|
|
103
|
-
* // Action generator using apiFetch
|
|
104
|
-
* export function* myAction() {
|
|
105
|
-
* const promise = getItemsAsync();
|
|
106
|
-
* const items = yield __unstableAwaitPromise( promise );
|
|
107
|
-
* // do something with the items.
|
|
108
|
-
* }
|
|
109
|
-
* ```
|
|
110
|
-
*
|
|
111
|
-
* @return {Object} The control descriptor.
|
|
112
|
-
*/
|
|
113
|
-
const __unstableAwaitPromise = function (promise) {
|
|
73
|
+
const __unstableAwaitPromise = function(promise) {
|
|
114
74
|
return {
|
|
115
|
-
type:
|
|
75
|
+
type: "AWAIT_PROMISE",
|
|
116
76
|
promise
|
|
117
77
|
};
|
|
118
78
|
};
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
* The default export is what you use to register the controls with your custom
|
|
122
|
-
* store.
|
|
123
|
-
*
|
|
124
|
-
* @example
|
|
125
|
-
* ```js
|
|
126
|
-
* // WordPress dependencies
|
|
127
|
-
* import { controls } from '@wordpress/data-controls';
|
|
128
|
-
* import { registerStore } from '@wordpress/data';
|
|
129
|
-
*
|
|
130
|
-
* // Internal dependencies
|
|
131
|
-
* import reducer from './reducer';
|
|
132
|
-
* import * as selectors from './selectors';
|
|
133
|
-
* import * as actions from './actions';
|
|
134
|
-
* import * as resolvers from './resolvers';
|
|
135
|
-
*
|
|
136
|
-
* registerStore( 'my-custom-store', {
|
|
137
|
-
* reducer,
|
|
138
|
-
* controls,
|
|
139
|
-
* actions,
|
|
140
|
-
* selectors,
|
|
141
|
-
* resolvers,
|
|
142
|
-
* } );
|
|
143
|
-
* ```
|
|
144
|
-
* @return {Object} An object for registering the default controls with the
|
|
145
|
-
* store.
|
|
146
|
-
*/
|
|
147
|
-
exports.__unstableAwaitPromise = __unstableAwaitPromise;
|
|
148
|
-
const controls = exports.controls = {
|
|
149
|
-
AWAIT_PROMISE({
|
|
150
|
-
promise
|
|
151
|
-
}) {
|
|
79
|
+
const controls = {
|
|
80
|
+
AWAIT_PROMISE({ promise }) {
|
|
152
81
|
return promise;
|
|
153
82
|
},
|
|
154
|
-
API_FETCH({
|
|
155
|
-
request
|
|
156
|
-
}) {
|
|
157
|
-
return (0, _apiFetch.default)(request);
|
|
83
|
+
API_FETCH({ request }) {
|
|
84
|
+
return (0, import_api_fetch.default)(request);
|
|
158
85
|
}
|
|
159
86
|
};
|
|
160
|
-
|
|
87
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
88
|
+
0 && (module.exports = {
|
|
89
|
+
__unstableAwaitPromise,
|
|
90
|
+
apiFetch,
|
|
91
|
+
controls,
|
|
92
|
+
dispatch,
|
|
93
|
+
select,
|
|
94
|
+
syncSelect
|
|
95
|
+
});
|
|
96
|
+
//# sourceMappingURL=index.js.map
|
package/build/index.js.map
CHANGED
|
@@ -1 +1,7 @@
|
|
|
1
|
-
{
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/index.ts"],
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport triggerFetch from '@wordpress/api-fetch';\nimport { controls as dataControls } from '@wordpress/data';\nimport deprecated from '@wordpress/deprecated';\nimport type { StoreDescriptor } from '@wordpress/data';\nimport type { APIFetchOptions } from '@wordpress/api-fetch';\n\n/**\n * Dispatches a control action for triggering an api fetch call.\n *\n * @param {Object} request Arguments for the fetch request.\n *\n * @example\n * ```js\n * import { apiFetch } from '@wordpress/data-controls';\n *\n * // Action generator using apiFetch\n * export function* myAction() {\n * \tconst path = '/v2/my-api/items';\n * \tconst items = yield apiFetch( { path } );\n * \t// do something with the items.\n * }\n * ```\n *\n * @return {Object} The control descriptor.\n */\nexport function apiFetch( request: APIFetchOptions ) {\n\treturn {\n\t\ttype: 'API_FETCH',\n\t\trequest,\n\t};\n}\n\n/**\n * Control for resolving a selector in a registered data store.\n * Alias for the `resolveSelect` built-in control in the `@wordpress/data` package.\n *\n * @param storeNameOrDescriptor The store object or identifier.\n * @param selectorName The selector name.\n * @param args Arguments passed without change to the `@wordpress/data` control.\n */\nexport function select(\n\tstoreNameOrDescriptor: string | StoreDescriptor,\n\tselectorName: string,\n\t...args: any[]\n) {\n\tdeprecated( '`select` control in `@wordpress/data-controls`', {\n\t\tsince: '5.7',\n\t\talternative: 'built-in `resolveSelect` control in `@wordpress/data`',\n\t} );\n\n\treturn dataControls.resolveSelect(\n\t\tstoreNameOrDescriptor,\n\t\tselectorName,\n\t\t...args\n\t);\n}\n\n/**\n * Control for calling a selector in a registered data store.\n * Alias for the `select` built-in control in the `@wordpress/data` package.\n *\n * @param storeNameOrDescriptor The store object or identifier.\n * @param selectorName The selector name.\n * @param args Arguments passed without change to the `@wordpress/data` control.\n */\nexport function syncSelect(\n\tstoreNameOrDescriptor: string | StoreDescriptor,\n\tselectorName: string,\n\t...args: any[]\n) {\n\tdeprecated( '`syncSelect` control in `@wordpress/data-controls`', {\n\t\tsince: '5.7',\n\t\talternative: 'built-in `select` control in `@wordpress/data`',\n\t} );\n\n\treturn dataControls.select( storeNameOrDescriptor, selectorName, ...args );\n}\n\n/**\n * Control for dispatching an action in a registered data store.\n * Alias for the `dispatch` control in the `@wordpress/data` package.\n *\n * @param storeNameOrDescriptor The store object or identifier.\n * @param actionName The action name.\n * @param args Arguments passed without change to the `@wordpress/data` control.\n */\nexport function dispatch(\n\tstoreNameOrDescriptor: string | StoreDescriptor,\n\tactionName: string,\n\t...args: any[]\n) {\n\tdeprecated( '`dispatch` control in `@wordpress/data-controls`', {\n\t\tsince: '5.7',\n\t\talternative: 'built-in `dispatch` control in `@wordpress/data`',\n\t} );\n\n\treturn dataControls.dispatch( storeNameOrDescriptor, actionName, ...args );\n}\n\n/**\n * Dispatches a control action for awaiting on a promise to be resolved.\n *\n * @param {Object} promise Promise to wait for.\n *\n * @example\n * ```js\n * import { __unstableAwaitPromise } from '@wordpress/data-controls';\n *\n * // Action generator using apiFetch\n * export function* myAction() {\n * \tconst promise = getItemsAsync();\n * \tconst items = yield __unstableAwaitPromise( promise );\n * \t// do something with the items.\n * }\n * ```\n *\n * @return {Object} The control descriptor.\n */\nexport const __unstableAwaitPromise = function < T >( promise: Promise< T > ) {\n\treturn {\n\t\ttype: 'AWAIT_PROMISE',\n\t\tpromise,\n\t};\n};\n\n/**\n * The default export is what you use to register the controls with your custom\n * store.\n *\n * @example\n * ```js\n * // WordPress dependencies\n * import { controls } from '@wordpress/data-controls';\n * import { registerStore } from '@wordpress/data';\n *\n * // Internal dependencies\n * import reducer from './reducer';\n * import * as selectors from './selectors';\n * import * as actions from './actions';\n * import * as resolvers from './resolvers';\n *\n * registerStore( 'my-custom-store', {\n * reducer,\n * controls,\n * actions,\n * selectors,\n * resolvers,\n * } );\n * ```\n * @return {Object} An object for registering the default controls with the\n * store.\n */\nexport const controls = {\n\tAWAIT_PROMISE< T >( { promise }: { promise: Promise< T > } ) {\n\t\treturn promise;\n\t},\n\tAPI_FETCH( { request }: { request: APIFetchOptions } ) {\n\t\treturn triggerFetch( request );\n\t},\n};\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,uBAAyB;AACzB,kBAAyC;AACzC,wBAAuB;AAuBhB,SAAS,SAAU,SAA2B;AACpD,SAAO;AAAA,IACN,MAAM;AAAA,IACN;AAAA,EACD;AACD;AAUO,SAAS,OACf,uBACA,iBACG,MACF;AACD,wBAAAA,SAAY,kDAAkD;AAAA,IAC7D,OAAO;AAAA,IACP,aAAa;AAAA,EACd,CAAE;AAEF,SAAO,YAAAC,SAAa;AAAA,IACnB;AAAA,IACA;AAAA,IACA,GAAG;AAAA,EACJ;AACD;AAUO,SAAS,WACf,uBACA,iBACG,MACF;AACD,wBAAAD,SAAY,sDAAsD;AAAA,IACjE,OAAO;AAAA,IACP,aAAa;AAAA,EACd,CAAE;AAEF,SAAO,YAAAC,SAAa,OAAQ,uBAAuB,cAAc,GAAG,IAAK;AAC1E;AAUO,SAAS,SACf,uBACA,eACG,MACF;AACD,wBAAAD,SAAY,oDAAoD;AAAA,IAC/D,OAAO;AAAA,IACP,aAAa;AAAA,EACd,CAAE;AAEF,SAAO,YAAAC,SAAa,SAAU,uBAAuB,YAAY,GAAG,IAAK;AAC1E;AAqBO,MAAM,yBAAyB,SAAgB,SAAwB;AAC7E,SAAO;AAAA,IACN,MAAM;AAAA,IACN;AAAA,EACD;AACD;AA6BO,MAAM,WAAW;AAAA,EACvB,cAAoB,EAAE,QAAQ,GAA+B;AAC5D,WAAO;AAAA,EACR;AAAA,EACA,UAAW,EAAE,QAAQ,GAAkC;AACtD,eAAO,iBAAAC,SAAc,OAAQ;AAAA,EAC9B;AACD;",
|
|
6
|
+
"names": ["deprecated", "dataControls", "triggerFetch"]
|
|
7
|
+
}
|
package/build-module/index.js
CHANGED
|
@@ -1,146 +1,57 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
import { controls as dataControls } from '@wordpress/data';
|
|
6
|
-
import deprecated from '@wordpress/deprecated';
|
|
7
|
-
/**
|
|
8
|
-
* Dispatches a control action for triggering an api fetch call.
|
|
9
|
-
*
|
|
10
|
-
* @param {Object} request Arguments for the fetch request.
|
|
11
|
-
*
|
|
12
|
-
* @example
|
|
13
|
-
* ```js
|
|
14
|
-
* import { apiFetch } from '@wordpress/data-controls';
|
|
15
|
-
*
|
|
16
|
-
* // Action generator using apiFetch
|
|
17
|
-
* export function* myAction() {
|
|
18
|
-
* const path = '/v2/my-api/items';
|
|
19
|
-
* const items = yield apiFetch( { path } );
|
|
20
|
-
* // do something with the items.
|
|
21
|
-
* }
|
|
22
|
-
* ```
|
|
23
|
-
*
|
|
24
|
-
* @return {Object} The control descriptor.
|
|
25
|
-
*/
|
|
26
|
-
export function apiFetch(request) {
|
|
1
|
+
import triggerFetch from "@wordpress/api-fetch";
|
|
2
|
+
import { controls as dataControls } from "@wordpress/data";
|
|
3
|
+
import deprecated from "@wordpress/deprecated";
|
|
4
|
+
function apiFetch(request) {
|
|
27
5
|
return {
|
|
28
|
-
type:
|
|
6
|
+
type: "API_FETCH",
|
|
29
7
|
request
|
|
30
8
|
};
|
|
31
9
|
}
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
*
|
|
37
|
-
* @param storeNameOrDescriptor The store object or identifier.
|
|
38
|
-
* @param selectorName The selector name.
|
|
39
|
-
* @param args Arguments passed without change to the `@wordpress/data` control.
|
|
40
|
-
*/
|
|
41
|
-
export function select(storeNameOrDescriptor, selectorName, ...args) {
|
|
42
|
-
deprecated('`select` control in `@wordpress/data-controls`', {
|
|
43
|
-
since: '5.7',
|
|
44
|
-
alternative: 'built-in `resolveSelect` control in `@wordpress/data`'
|
|
10
|
+
function select(storeNameOrDescriptor, selectorName, ...args) {
|
|
11
|
+
deprecated("`select` control in `@wordpress/data-controls`", {
|
|
12
|
+
since: "5.7",
|
|
13
|
+
alternative: "built-in `resolveSelect` control in `@wordpress/data`"
|
|
45
14
|
});
|
|
46
|
-
return dataControls.resolveSelect(
|
|
15
|
+
return dataControls.resolveSelect(
|
|
16
|
+
storeNameOrDescriptor,
|
|
17
|
+
selectorName,
|
|
18
|
+
...args
|
|
19
|
+
);
|
|
47
20
|
}
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
*
|
|
53
|
-
* @param storeNameOrDescriptor The store object or identifier.
|
|
54
|
-
* @param selectorName The selector name.
|
|
55
|
-
* @param args Arguments passed without change to the `@wordpress/data` control.
|
|
56
|
-
*/
|
|
57
|
-
export function syncSelect(storeNameOrDescriptor, selectorName, ...args) {
|
|
58
|
-
deprecated('`syncSelect` control in `@wordpress/data-controls`', {
|
|
59
|
-
since: '5.7',
|
|
60
|
-
alternative: 'built-in `select` control in `@wordpress/data`'
|
|
21
|
+
function syncSelect(storeNameOrDescriptor, selectorName, ...args) {
|
|
22
|
+
deprecated("`syncSelect` control in `@wordpress/data-controls`", {
|
|
23
|
+
since: "5.7",
|
|
24
|
+
alternative: "built-in `select` control in `@wordpress/data`"
|
|
61
25
|
});
|
|
62
26
|
return dataControls.select(storeNameOrDescriptor, selectorName, ...args);
|
|
63
27
|
}
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
*
|
|
69
|
-
* @param storeNameOrDescriptor The store object or identifier.
|
|
70
|
-
* @param actionName The action name.
|
|
71
|
-
* @param args Arguments passed without change to the `@wordpress/data` control.
|
|
72
|
-
*/
|
|
73
|
-
export function dispatch(storeNameOrDescriptor, actionName, ...args) {
|
|
74
|
-
deprecated('`dispatch` control in `@wordpress/data-controls`', {
|
|
75
|
-
since: '5.7',
|
|
76
|
-
alternative: 'built-in `dispatch` control in `@wordpress/data`'
|
|
28
|
+
function dispatch(storeNameOrDescriptor, actionName, ...args) {
|
|
29
|
+
deprecated("`dispatch` control in `@wordpress/data-controls`", {
|
|
30
|
+
since: "5.7",
|
|
31
|
+
alternative: "built-in `dispatch` control in `@wordpress/data`"
|
|
77
32
|
});
|
|
78
33
|
return dataControls.dispatch(storeNameOrDescriptor, actionName, ...args);
|
|
79
34
|
}
|
|
80
|
-
|
|
81
|
-
/**
|
|
82
|
-
* Dispatches a control action for awaiting on a promise to be resolved.
|
|
83
|
-
*
|
|
84
|
-
* @param {Object} promise Promise to wait for.
|
|
85
|
-
*
|
|
86
|
-
* @example
|
|
87
|
-
* ```js
|
|
88
|
-
* import { __unstableAwaitPromise } from '@wordpress/data-controls';
|
|
89
|
-
*
|
|
90
|
-
* // Action generator using apiFetch
|
|
91
|
-
* export function* myAction() {
|
|
92
|
-
* const promise = getItemsAsync();
|
|
93
|
-
* const items = yield __unstableAwaitPromise( promise );
|
|
94
|
-
* // do something with the items.
|
|
95
|
-
* }
|
|
96
|
-
* ```
|
|
97
|
-
*
|
|
98
|
-
* @return {Object} The control descriptor.
|
|
99
|
-
*/
|
|
100
|
-
export const __unstableAwaitPromise = function (promise) {
|
|
35
|
+
const __unstableAwaitPromise = function(promise) {
|
|
101
36
|
return {
|
|
102
|
-
type:
|
|
37
|
+
type: "AWAIT_PROMISE",
|
|
103
38
|
promise
|
|
104
39
|
};
|
|
105
40
|
};
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
* The default export is what you use to register the controls with your custom
|
|
109
|
-
* store.
|
|
110
|
-
*
|
|
111
|
-
* @example
|
|
112
|
-
* ```js
|
|
113
|
-
* // WordPress dependencies
|
|
114
|
-
* import { controls } from '@wordpress/data-controls';
|
|
115
|
-
* import { registerStore } from '@wordpress/data';
|
|
116
|
-
*
|
|
117
|
-
* // Internal dependencies
|
|
118
|
-
* import reducer from './reducer';
|
|
119
|
-
* import * as selectors from './selectors';
|
|
120
|
-
* import * as actions from './actions';
|
|
121
|
-
* import * as resolvers from './resolvers';
|
|
122
|
-
*
|
|
123
|
-
* registerStore( 'my-custom-store', {
|
|
124
|
-
* reducer,
|
|
125
|
-
* controls,
|
|
126
|
-
* actions,
|
|
127
|
-
* selectors,
|
|
128
|
-
* resolvers,
|
|
129
|
-
* } );
|
|
130
|
-
* ```
|
|
131
|
-
* @return {Object} An object for registering the default controls with the
|
|
132
|
-
* store.
|
|
133
|
-
*/
|
|
134
|
-
export const controls = {
|
|
135
|
-
AWAIT_PROMISE({
|
|
136
|
-
promise
|
|
137
|
-
}) {
|
|
41
|
+
const controls = {
|
|
42
|
+
AWAIT_PROMISE({ promise }) {
|
|
138
43
|
return promise;
|
|
139
44
|
},
|
|
140
|
-
API_FETCH({
|
|
141
|
-
request
|
|
142
|
-
}) {
|
|
45
|
+
API_FETCH({ request }) {
|
|
143
46
|
return triggerFetch(request);
|
|
144
47
|
}
|
|
145
48
|
};
|
|
146
|
-
|
|
49
|
+
export {
|
|
50
|
+
__unstableAwaitPromise,
|
|
51
|
+
apiFetch,
|
|
52
|
+
controls,
|
|
53
|
+
dispatch,
|
|
54
|
+
select,
|
|
55
|
+
syncSelect
|
|
56
|
+
};
|
|
57
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1,7 @@
|
|
|
1
|
-
{
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/index.ts"],
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport triggerFetch from '@wordpress/api-fetch';\nimport { controls as dataControls } from '@wordpress/data';\nimport deprecated from '@wordpress/deprecated';\nimport type { StoreDescriptor } from '@wordpress/data';\nimport type { APIFetchOptions } from '@wordpress/api-fetch';\n\n/**\n * Dispatches a control action for triggering an api fetch call.\n *\n * @param {Object} request Arguments for the fetch request.\n *\n * @example\n * ```js\n * import { apiFetch } from '@wordpress/data-controls';\n *\n * // Action generator using apiFetch\n * export function* myAction() {\n * \tconst path = '/v2/my-api/items';\n * \tconst items = yield apiFetch( { path } );\n * \t// do something with the items.\n * }\n * ```\n *\n * @return {Object} The control descriptor.\n */\nexport function apiFetch( request: APIFetchOptions ) {\n\treturn {\n\t\ttype: 'API_FETCH',\n\t\trequest,\n\t};\n}\n\n/**\n * Control for resolving a selector in a registered data store.\n * Alias for the `resolveSelect` built-in control in the `@wordpress/data` package.\n *\n * @param storeNameOrDescriptor The store object or identifier.\n * @param selectorName The selector name.\n * @param args Arguments passed without change to the `@wordpress/data` control.\n */\nexport function select(\n\tstoreNameOrDescriptor: string | StoreDescriptor,\n\tselectorName: string,\n\t...args: any[]\n) {\n\tdeprecated( '`select` control in `@wordpress/data-controls`', {\n\t\tsince: '5.7',\n\t\talternative: 'built-in `resolveSelect` control in `@wordpress/data`',\n\t} );\n\n\treturn dataControls.resolveSelect(\n\t\tstoreNameOrDescriptor,\n\t\tselectorName,\n\t\t...args\n\t);\n}\n\n/**\n * Control for calling a selector in a registered data store.\n * Alias for the `select` built-in control in the `@wordpress/data` package.\n *\n * @param storeNameOrDescriptor The store object or identifier.\n * @param selectorName The selector name.\n * @param args Arguments passed without change to the `@wordpress/data` control.\n */\nexport function syncSelect(\n\tstoreNameOrDescriptor: string | StoreDescriptor,\n\tselectorName: string,\n\t...args: any[]\n) {\n\tdeprecated( '`syncSelect` control in `@wordpress/data-controls`', {\n\t\tsince: '5.7',\n\t\talternative: 'built-in `select` control in `@wordpress/data`',\n\t} );\n\n\treturn dataControls.select( storeNameOrDescriptor, selectorName, ...args );\n}\n\n/**\n * Control for dispatching an action in a registered data store.\n * Alias for the `dispatch` control in the `@wordpress/data` package.\n *\n * @param storeNameOrDescriptor The store object or identifier.\n * @param actionName The action name.\n * @param args Arguments passed without change to the `@wordpress/data` control.\n */\nexport function dispatch(\n\tstoreNameOrDescriptor: string | StoreDescriptor,\n\tactionName: string,\n\t...args: any[]\n) {\n\tdeprecated( '`dispatch` control in `@wordpress/data-controls`', {\n\t\tsince: '5.7',\n\t\talternative: 'built-in `dispatch` control in `@wordpress/data`',\n\t} );\n\n\treturn dataControls.dispatch( storeNameOrDescriptor, actionName, ...args );\n}\n\n/**\n * Dispatches a control action for awaiting on a promise to be resolved.\n *\n * @param {Object} promise Promise to wait for.\n *\n * @example\n * ```js\n * import { __unstableAwaitPromise } from '@wordpress/data-controls';\n *\n * // Action generator using apiFetch\n * export function* myAction() {\n * \tconst promise = getItemsAsync();\n * \tconst items = yield __unstableAwaitPromise( promise );\n * \t// do something with the items.\n * }\n * ```\n *\n * @return {Object} The control descriptor.\n */\nexport const __unstableAwaitPromise = function < T >( promise: Promise< T > ) {\n\treturn {\n\t\ttype: 'AWAIT_PROMISE',\n\t\tpromise,\n\t};\n};\n\n/**\n * The default export is what you use to register the controls with your custom\n * store.\n *\n * @example\n * ```js\n * // WordPress dependencies\n * import { controls } from '@wordpress/data-controls';\n * import { registerStore } from '@wordpress/data';\n *\n * // Internal dependencies\n * import reducer from './reducer';\n * import * as selectors from './selectors';\n * import * as actions from './actions';\n * import * as resolvers from './resolvers';\n *\n * registerStore( 'my-custom-store', {\n * reducer,\n * controls,\n * actions,\n * selectors,\n * resolvers,\n * } );\n * ```\n * @return {Object} An object for registering the default controls with the\n * store.\n */\nexport const controls = {\n\tAWAIT_PROMISE< T >( { promise }: { promise: Promise< T > } ) {\n\t\treturn promise;\n\t},\n\tAPI_FETCH( { request }: { request: APIFetchOptions } ) {\n\t\treturn triggerFetch( request );\n\t},\n};\n"],
|
|
5
|
+
"mappings": "AAGA,OAAO,kBAAkB;AACzB,SAAS,YAAY,oBAAoB;AACzC,OAAO,gBAAgB;AAuBhB,SAAS,SAAU,SAA2B;AACpD,SAAO;AAAA,IACN,MAAM;AAAA,IACN;AAAA,EACD;AACD;AAUO,SAAS,OACf,uBACA,iBACG,MACF;AACD,aAAY,kDAAkD;AAAA,IAC7D,OAAO;AAAA,IACP,aAAa;AAAA,EACd,CAAE;AAEF,SAAO,aAAa;AAAA,IACnB;AAAA,IACA;AAAA,IACA,GAAG;AAAA,EACJ;AACD;AAUO,SAAS,WACf,uBACA,iBACG,MACF;AACD,aAAY,sDAAsD;AAAA,IACjE,OAAO;AAAA,IACP,aAAa;AAAA,EACd,CAAE;AAEF,SAAO,aAAa,OAAQ,uBAAuB,cAAc,GAAG,IAAK;AAC1E;AAUO,SAAS,SACf,uBACA,eACG,MACF;AACD,aAAY,oDAAoD;AAAA,IAC/D,OAAO;AAAA,IACP,aAAa;AAAA,EACd,CAAE;AAEF,SAAO,aAAa,SAAU,uBAAuB,YAAY,GAAG,IAAK;AAC1E;AAqBO,MAAM,yBAAyB,SAAgB,SAAwB;AAC7E,SAAO;AAAA,IACN,MAAM;AAAA,IACN;AAAA,EACD;AACD;AA6BO,MAAM,WAAW;AAAA,EACvB,cAAoB,EAAE,QAAQ,GAA+B;AAC5D,WAAO;AAAA,EACR;AAAA,EACA,UAAW,EAAE,QAAQ,GAAkC;AACtD,WAAO,aAAc,OAAQ;AAAA,EAC9B;AACD;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wordpress/data-controls",
|
|
3
|
-
"version": "4.32.0",
|
|
3
|
+
"version": "4.32.1-next.47f435fc9.0",
|
|
4
4
|
"description": "A set of common controls for the @wordpress/data api.",
|
|
5
5
|
"author": "The WordPress Contributors",
|
|
6
6
|
"license": "GPL-2.0-or-later",
|
|
@@ -25,14 +25,21 @@
|
|
|
25
25
|
},
|
|
26
26
|
"main": "build/index.js",
|
|
27
27
|
"module": "build-module/index.js",
|
|
28
|
+
"exports": {
|
|
29
|
+
".": {
|
|
30
|
+
"types": "./build-types/index.d.ts",
|
|
31
|
+
"import": "./build-module/index.js",
|
|
32
|
+
"require": "./build/index.js"
|
|
33
|
+
},
|
|
34
|
+
"./package.json": "./package.json"
|
|
35
|
+
},
|
|
28
36
|
"react-native": "src/index",
|
|
29
37
|
"wpScript": true,
|
|
30
38
|
"types": "build-types",
|
|
31
39
|
"dependencies": {
|
|
32
|
-
"@
|
|
33
|
-
"@wordpress/
|
|
34
|
-
"@wordpress/
|
|
35
|
-
"@wordpress/deprecated": "^4.32.0"
|
|
40
|
+
"@wordpress/api-fetch": "^7.32.1-next.47f435fc9.0",
|
|
41
|
+
"@wordpress/data": "^10.32.1-next.47f435fc9.0",
|
|
42
|
+
"@wordpress/deprecated": "^4.32.1-next.47f435fc9.0"
|
|
36
43
|
},
|
|
37
44
|
"peerDependencies": {
|
|
38
45
|
"react": "^18.0.0"
|
|
@@ -40,5 +47,5 @@
|
|
|
40
47
|
"publishConfig": {
|
|
41
48
|
"access": "public"
|
|
42
49
|
},
|
|
43
|
-
"gitHead": "
|
|
50
|
+
"gitHead": "9720f22c138771d2ed1a0522725c3cdf1c242953"
|
|
44
51
|
}
|